Java Code Examples for com.helger.commons.collection.impl.CommonsArrayList#addAll()

The following examples show how to use com.helger.commons.collection.impl.CommonsArrayList#addAll() . 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: CollectionHelper.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
@Nullable
@ReturnsMutableCopy
public static <ELEMENTTYPE> CommonsArrayList <ELEMENTTYPE> getConcatenatedList (@Nullable final Collection <? extends ELEMENTTYPE> aCollection1,
                                                                                @Nullable final Collection <? extends ELEMENTTYPE> aCollection2)
{
  final int nSize1 = getSize (aCollection1);
  if (nSize1 == 0)
    return newList (aCollection2);

  final int nSize2 = getSize (aCollection2);
  if (nSize2 == 0)
    return newList (aCollection1);

  final CommonsArrayList <ELEMENTTYPE> ret = newList (nSize1 + nSize2);
  ret.addAll (aCollection1);
  ret.addAll (aCollection2);
  return ret;
}
 
Example 2
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
@Nullable
@ReturnsMutableCopy
@SafeVarargs
public static <ELEMENTTYPE> CommonsArrayList <ELEMENTTYPE> getConcatenatedList (@Nullable final Collection <? extends ELEMENTTYPE> aCont1,
                                                                                @Nullable final ELEMENTTYPE... aCont2)
{
  final int nSize1 = getSize (aCont1);
  if (nSize1 == 0)
    return newList (aCont2);

  final int nSize2 = ArrayHelper.getSize (aCont2);
  if (nSize2 == 0)
    return newList (aCont1);

  final CommonsArrayList <ELEMENTTYPE> ret = newList (nSize1 + nSize2);
  ret.addAll (aCont1);
  Collections.addAll (ret, aCont2);
  return ret;
}
 
Example 3
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
@Nullable
@ReturnsMutableCopy
public static <ELEMENTTYPE> CommonsArrayList <ELEMENTTYPE> getConcatenatedList (@Nullable final ELEMENTTYPE [] aCont1,
                                                                                @Nullable final Collection <? extends ELEMENTTYPE> aCont2)
{
  final int nSize1 = ArrayHelper.getSize (aCont1);
  if (nSize1 == 0)
    return newList (aCont2);

  final int nSize2 = getSize (aCont2);
  if (nSize2 == 0)
    return newList (aCont1);

  final CommonsArrayList <ELEMENTTYPE> ret = newList (nSize1 + nSize2);
  Collections.addAll (ret, aCont1);
  ret.addAll (aCont2);
  return ret;
}
 
Example 4
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
@SafeVarargs
public static <ELEMENTTYPE> CommonsArrayList <ELEMENTTYPE> newList (@Nullable final ELEMENTTYPE... aValues)
{
  // Don't user Arrays.asList since aIter returns an unmodifiable list!
  if (ArrayHelper.isEmpty (aValues))
    return newList (0);

  final CommonsArrayList <ELEMENTTYPE> ret = newList (aValues.length);
  ret.addAll (aValues);
  return ret;
}
 
Example 5
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> CommonsArrayList <ELEMENTTYPE> newList (@Nullable final Iterator <? extends ELEMENTTYPE> aIter)
{
  final CommonsArrayList <ELEMENTTYPE> ret = newList ();
  ret.addAll (aIter);
  return ret;
}
 
Example 6
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> CommonsArrayList <ELEMENTTYPE> newList (@Nullable final Iterable <? extends ELEMENTTYPE> aIter)
{
  final CommonsArrayList <ELEMENTTYPE> ret = newList ();
  ret.addAll (aIter);
  return ret;
}
 
Example 7
Source File: CollectionHelper.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Compared to {@link Collections#list(Enumeration)} this method is more
 * flexible in Generics parameter.
 *
 * @param <ELEMENTTYPE>
 *        Type of the elements
 * @param aEnum
 *        The enumeration to be converted
 * @return The non-<code>null</code> created {@link CommonsArrayList}.
 * @see Collections#list(Enumeration)
 */
@Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> CommonsArrayList <ELEMENTTYPE> newList (@Nullable final Enumeration <? extends ELEMENTTYPE> aEnum)
{
  final CommonsArrayList <ELEMENTTYPE> ret = newList ();
  ret.addAll (aEnum);
  return ret;
}