com.helger.commons.annotation.CodingStyleguideUnaware Java Examples

The following examples show how to use com.helger.commons.annotation.CodingStyleguideUnaware. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ValueEnforcer.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Check that the passed map is neither <code>null</code> nor empty and that
 * no <code>null</code> key or value is contained.
 *
 * @param <T>
 *        Type to be checked and returned
 * @param aValue
 *        The map to check. May be <code>null</code>.
 * @param aName
 *        The name of the value (e.g. the parameter name)
 * @return The passed value. Maybe <code>null</code>.
 * @throws IllegalArgumentException
 *         if the passed value is not empty and a <code>null</code> key or
 *         <code>null</code> value is contained
 */
@Nullable
@CodingStyleguideUnaware
public static <T extends Map <?, ?>> T noNullValue (final T aValue, @Nonnull final Supplier <? extends String> aName)
{
  if (isEnabled ())
    if (aValue != null)
    {
      for (final Map.Entry <?, ?> aEntry : aValue.entrySet ())
      {
        if (aEntry.getKey () == null)
          throw new IllegalArgumentException ("A key of map '" + aName.get () + "' may not be null!");
        if (aEntry.getValue () == null)
          throw new IllegalArgumentException ("A value of map '" + aName.get () + "' may not be null!");
      }
    }
  return aValue;
}
 
Example #2
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nullable
@ReturnsImmutableObject
@CodingStyleguideUnaware
public static <KEYTYPE, VALUETYPE> NavigableMap <KEYTYPE, VALUETYPE> makeUnmodifiable (@Nullable final NavigableMap <KEYTYPE, VALUETYPE> aNavigableMap)
{
  return aNavigableMap == null ? null : Collections.unmodifiableNavigableMap (aNavigableMap);
}
 
Example #3
Source File: SingleElementMap.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@ReturnsImmutableObject
@Nonnull
@CodingStyleguideUnaware
public Set <KEYTYPE> keySet ()
{
  return m_bHasElement ? new CommonsHashSet <> (m_aKey) : new CommonsHashSet <> ();
}
 
Example #4
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsImmutableObject
@CodingStyleguideUnaware
public static <ELEMENTTYPE> Collection <ELEMENTTYPE> makeUnmodifiableNotNull (@Nullable final Collection <ELEMENTTYPE> aCollection)
{
  return aCollection == null ? Collections.emptyList () : Collections.unmodifiableCollection (aCollection);
}
 
Example #5
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsImmutableObject
@CodingStyleguideUnaware
public static <ELEMENTTYPE> List <ELEMENTTYPE> makeUnmodifiableNotNull (@Nullable final List <ELEMENTTYPE> aList)
{
  return aList == null ? Collections.emptyList () : Collections.unmodifiableList (aList);
}
 
Example #6
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsImmutableObject
@CodingStyleguideUnaware
public static <ELEMENTTYPE> Set <ELEMENTTYPE> makeUnmodifiableNotNull (@Nullable final Set <ELEMENTTYPE> aSet)
{
  return aSet == null ? Collections.emptySet () : Collections.unmodifiableSet (aSet);
}
 
Example #7
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsImmutableObject
@CodingStyleguideUnaware
public static <KEYTYPE, VALUETYPE> Map <KEYTYPE, VALUETYPE> makeUnmodifiableNotNull (@Nullable final Map <KEYTYPE, VALUETYPE> aMap)
{
  return aMap == null ? Collections.emptyMap () : Collections.unmodifiableMap (aMap);
}
 
Example #8
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsImmutableObject
@CodingStyleguideUnaware
public static <ELEMENTTYPE extends Comparable <? super ELEMENTTYPE>> NavigableSet <ELEMENTTYPE> makeUnmodifiableNotNull (@Nullable final NavigableSet <ELEMENTTYPE> aNavigableSet)
{
  return aNavigableSet == null ? Collections.emptyNavigableSet ()
                               : Collections.unmodifiableNavigableSet (aNavigableSet);
}
 
Example #9
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsImmutableObject
@CodingStyleguideUnaware
public static <KEYTYPE extends Comparable <? super KEYTYPE>, VALUETYPE> NavigableMap <KEYTYPE, VALUETYPE> makeUnmodifiableNotNull (@Nullable final NavigableMap <KEYTYPE, VALUETYPE> aNavigableMap)
{
  return aNavigableMap == null ? Collections.emptyNavigableMap ()
                               : Collections.unmodifiableNavigableMap (aNavigableMap);
}
 
Example #10
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nullable
@ReturnsMutableObject ("design")
@CodingStyleguideUnaware
public static <ELEMENTTYPE extends Comparable <? super ELEMENTTYPE>, LISTTYPE extends List <ELEMENTTYPE>> LISTTYPE getSortedInline (@Nullable final LISTTYPE aList)
{
  if (isNotEmpty (aList))
    aList.sort (null);
  return aList;
}
 
Example #11
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nullable
@ReturnsMutableObject ("design")
@CodingStyleguideUnaware
public static <ELEMENTTYPE, LISTTYPE extends List <ELEMENTTYPE>> LISTTYPE getSortedInline (@Nullable final LISTTYPE aList,
                                                                                           @Nonnull final Comparator <? super ELEMENTTYPE> aComparator)
{
  ValueEnforcer.notNull (aComparator, "Comparator");

  if (isNotEmpty (aList))
    aList.sort (aComparator);
  return aList;
}
 
Example #12
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nullable
@ReturnsMutableObject ("semantics of this method")
@CodingStyleguideUnaware
public static <ELEMENTTYPE, LISTTYPE extends List <ELEMENTTYPE>> LISTTYPE getReverseInlineList (@Nullable final LISTTYPE aList)
{
  if (aList == null)
    return null;

  Collections.reverse (aList);
  return aList;
}
 
Example #13
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableObject ("design")
@SafeVarargs
@CodingStyleguideUnaware
public static <ELEMENTTYPE, COLLTYPE extends Collection <? super ELEMENTTYPE>> COLLTYPE getConcatenatedInline (@Nonnull final COLLTYPE aCont,
                                                                                                               @Nullable final ELEMENTTYPE... aElementsToAdd)
{
  ValueEnforcer.notNull (aCont, "Container");

  if (aElementsToAdd != null)
    Collections.addAll (aCont, aElementsToAdd);
  return aCont;
}
 
Example #14
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableObject ("design")
@CodingStyleguideUnaware
public static <ELEMENTTYPE, COLLTYPE extends Collection <? super ELEMENTTYPE>> COLLTYPE getConcatenatedInline (@Nonnull final COLLTYPE aCont,
                                                                                                               @Nullable final Collection <? extends ELEMENTTYPE> aElementsToAdd)
{
  ValueEnforcer.notNull (aCont, "Container");

  if (aElementsToAdd != null)
    aCont.addAll (aElementsToAdd);
  return aCont;
}
 
Example #15
Source File: ICommonsSortedMap.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
@CodingStyleguideUnaware
default SortedMap <KEYTYPE, VALUETYPE> getAsUnmodifiable ()
{
  return Collections.unmodifiableSortedMap (this);
}
 
Example #16
Source File: ICommonsList.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
@CodingStyleguideUnaware
default List <ELEMENTTYPE> getAsUnmodifiable ()
{
  return Collections.unmodifiableList (this);
}
 
Example #17
Source File: ICommonsNavigableSet.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
@CodingStyleguideUnaware
default NavigableSet <ELEMENTTYPE> getAsUnmodifiable ()
{
  return Collections.unmodifiableNavigableSet (this);
}
 
Example #18
Source File: ICommonsMap.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * @return An unmodifiable version of this map. Never <code>null</code>.
 * @see Collections
 */
@Nonnull
@CodingStyleguideUnaware
default Map <KEYTYPE, VALUETYPE> getAsUnmodifiable ()
{
  return Collections.unmodifiableMap (this);
}
 
Example #19
Source File: ICommonsNavigableMap.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
@CodingStyleguideUnaware
default NavigableMap <KEYTYPE, VALUETYPE> getAsUnmodifiable ()
{
  return Collections.unmodifiableNavigableMap (this);
}
 
Example #20
Source File: ICommonsSortedSet.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
@CodingStyleguideUnaware
default SortedSet <ELEMENTTYPE> getAsUnmodifiable ()
{
  return Collections.unmodifiableSortedSet (this);
}
 
Example #21
Source File: ICommonsCollection.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * @return An unmodifiable version of this collection. Never <code>null</code>
 *         .
 * @see Collections
 */
@Nonnull
@CodingStyleguideUnaware
default Collection <ELEMENTTYPE> getAsUnmodifiable ()
{
  return Collections.unmodifiableCollection (this);
}
 
Example #22
Source File: ICommonsSet.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
@CodingStyleguideUnaware
default Set <ELEMENTTYPE> getAsUnmodifiable ()
{
  return Collections.unmodifiableSet (this);
}
 
Example #23
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nullable
@ReturnsImmutableObject
@CodingStyleguideUnaware
public static <KEYTYPE, VALUETYPE> Map <KEYTYPE, VALUETYPE> makeUnmodifiable (@Nullable final Map <KEYTYPE, VALUETYPE> aMap)
{
  return aMap == null ? null : Collections.unmodifiableMap (aMap);
}
 
Example #24
Source File: SingleElementList.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@CodingStyleguideUnaware
public ICommonsList <ELEMENTTYPE> subList (@Nonnegative final int nFromIndex, @Nonnegative final int nToIndex)
{
  if (nFromIndex < 0 || nFromIndex > (m_bHasElement ? 1 : 0))
    throw new IndexOutOfBoundsException ("Invalid from index " + nFromIndex);
  if (nToIndex < 0 || nToIndex > (m_bHasElement ? 1 : 0))
    throw new IndexOutOfBoundsException ("Invalid to index " + nToIndex);

  // Empty
  if (!m_bHasElement || nFromIndex == nToIndex)
    return new CommonsArrayList <> (0);

  return this;
}
 
Example #25
Source File: SingleElementMap.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
@CodingStyleguideUnaware
public Set <Map.Entry <KEYTYPE, VALUETYPE>> entrySet ()
{
  final ICommonsSet <Map.Entry <KEYTYPE, VALUETYPE>> aSet = new CommonsHashSet <> (size ());
  if (m_bHasElement)
    aSet.add (new MapEntry <> (m_aKey, m_aValue));
  return aSet;
}
 
Example #26
Source File: WrappedCollection.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableObject ("design")
@CodingStyleguideUnaware
protected Collection <ELEMENTTYPE> directGetSource ()
{
  return m_aSrc;
}
 
Example #27
Source File: WrappedSet.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableObject ("design")
@CodingStyleguideUnaware
protected Set <ELEMENTTYPE> directGetSource ()
{
  return m_aSrc;
}
 
Example #28
Source File: WrappedList.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableObject ("design")
@CodingStyleguideUnaware
protected List <ELEMENTTYPE> directGetSource ()
{
  return m_aSrc;
}
 
Example #29
Source File: XMLResourceBundleControl.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Override
@ReturnsMutableCopy
@CodingStyleguideUnaware
public List <String> getFormats (@Nonnull final String sBaseName)
{
  ValueEnforcer.notNull (sBaseName, "BaseName");
  return FORMATS.getClone ();
}
 
Example #30
Source File: XMLResourceBundle.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * More efficient version to retrieve the keySet
 *
 * @return all resource names
 */
@Override
@CodingStyleguideUnaware
protected Set <String> handleKeySet ()
{
  return m_aValues.keySet ();
}