Class CommonsArrayList<ELEMENTTYPE>

java.lang.Object
java.util.AbstractCollection<ELEMENTTYPE>
java.util.AbstractList<ELEMENTTYPE>
java.util.ArrayList<ELEMENTTYPE>
com.helger.commons.collection.impl.CommonsArrayList<ELEMENTTYPE>
Type Parameters:
ELEMENTTYPE - List element type
All Implemented Interfaces:
ICommonsCollection<ELEMENTTYPE>, ICommonsIterable<ELEMENTTYPE>, ICommonsList<ELEMENTTYPE>, ICloneable<ICommonsList<ELEMENTTYPE>>, IHasSize, Serializable, Cloneable, Iterable<ELEMENTTYPE>, Collection<ELEMENTTYPE>, List<ELEMENTTYPE>, RandomAccess, SequencedCollection<ELEMENTTYPE>
Direct Known Subclasses:
ErrorList, NonBlockingStack, URLParameterList

public class CommonsArrayList<ELEMENTTYPE> extends ArrayList<ELEMENTTYPE> implements ICommonsList<ELEMENTTYPE>
A special ArrayList implementation based on ICommonsList.
Author:
Philip Helger
See Also:
  • Constructor Details

    • CommonsArrayList

      public CommonsArrayList()
      Create a new empty array list. The default initial capacity is used.
    • CommonsArrayList

      public CommonsArrayList(@Nonnegative int nInitialCapacity)
      Create a new empty array list.
      Parameters:
      nInitialCapacity - The initial capacity for which memory is reserved. Must be > 0.
    • CommonsArrayList

      public CommonsArrayList(@Nullable Collection<? extends ELEMENTTYPE> aValues)
      Create a new array list that contains the same elements as the provided collection.
      Parameters:
      aValues - The collection to copy the initial capacity and the elements from. May be null.
      See Also:
    • CommonsArrayList

      public CommonsArrayList(@Nullable Iterable<? extends ELEMENTTYPE> aValues)
      Create a new array list with the default initial capacity and add all provided elements.
      Parameters:
      aValues - The iterable from which the elements are copied from. May be null.
      See Also:
    • CommonsArrayList

      public CommonsArrayList(@Nullable Enumeration<? extends ELEMENTTYPE> aValues)
      Create a new array list with the default initial capacity and add all provided elements.
      Parameters:
      aValues - The iterable from which the elements are copied from. May be null.
      See Also:
    • CommonsArrayList

      public CommonsArrayList(@Nullable Collection<? extends SRCTYPE> aValues, @Nonnull Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper)
      Create a new array list that contains the mapped elements of the provided collection.
      Type Parameters:
      SRCTYPE - source data type
      Parameters:
      aValues - The collection to copy the initial capacity and the elements from. May be null.
      aMapper - The mapping function to be executed for all provided elements. May not be null.
      See Also:
    • CommonsArrayList

      public CommonsArrayList(@Nullable Iterable<? extends SRCTYPE> aValues, @Nonnull Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper)
      Create a new array list with the default initial capacity and add all mapped items of the provided iterable.
      Type Parameters:
      SRCTYPE - source data type
      Parameters:
      aValues - The iterable from which the elements are copied from. May be null.
      aMapper - The mapping function to be executed for all provided elements. May not be null.
      See Also:
    • CommonsArrayList

      public CommonsArrayList(@Nullable ELEMENTTYPE aValue)
      Create a new array list with an initial capacity of 1 and exactly the provided value, even if it is null.
      Parameters:
      aValue - The value to be added. May be null.
    • CommonsArrayList

      @SafeVarargs public CommonsArrayList(@Nullable ELEMENTTYPE... aValues)
      Create a new array list that contains the same elements as the provided array.
      Parameters:
      aValues - The array to copy the initial capacity and the elements from. May be null.
      See Also:
    • CommonsArrayList

      public CommonsArrayList(@Nullable SRCTYPE[] aValues, @Nonnull Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper)
      Create a new array list that contains mapped elements of the provided array.
      Type Parameters:
      SRCTYPE - source data type
      Parameters:
      aValues - The array to copy the initial capacity and the elements from. May be null.
      aMapper - The mapping function to be executed for all provided elements. May not be null.
      See Also:
  • Method Details

    • createInstance

      @Nonnull @ReturnsMutableCopy public <T> CommonsArrayList<T> createInstance()
      Description copied from interface: ICommonsList
      Create a new empty list. Overwrite this if you don't want to use CommonsArrayList.
      Specified by:
      createInstance in interface ICommonsList<ELEMENTTYPE>
      Type Parameters:
      T - List element type
      Returns:
      A new empty list. Never null.
    • getClone

      Specified by:
      getClone in interface ICloneable<ELEMENTTYPE>
      Returns:
      A 100% deep-copy of the implementing class.
    • createFiltered

      @Nonnull @ReturnsMutableCopy public static <ELEMENTTYPE> CommonsArrayList<ELEMENTTYPE> createFiltered(@Nullable Iterable<? extends ELEMENTTYPE> aValues, @Nullable Predicate<? super ELEMENTTYPE> aFilter)
      Create a new array list that contains a subset of the provided iterable.
      Note: this method is a static factory method because the compiler sometimes cannot deduce between Predicate and Function and the mapping case occurs more often.
      Type Parameters:
      ELEMENTTYPE - data type to create the list of
      Parameters:
      aValues - The iterable from which the elements are copied from. May be null.
      aFilter - The filter to be applied to check if the element should be added or not.
      Returns:
      The created array list. Never null.
      See Also:
    • createFiltered

      @Nonnull @ReturnsMutableCopy public static <SRCTYPE, ELEMENTTYPE> CommonsArrayList<ELEMENTTYPE> createFiltered(@Nullable Iterable<? extends SRCTYPE> aValues, @Nullable Predicate<? super SRCTYPE> aFilter, @Nonnull Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper)
      Create a new array list that contains a subset of the provided iterable. This method filters the elements before they are mapped.
      Note: this method is a static factory method because the compiler sometimes cannot deduce between Predicate and Function and the mapping case occurs more often.
      Type Parameters:
      SRCTYPE - source data type
      ELEMENTTYPE - final data type of the list
      Parameters:
      aValues - The iterable from which the elements are copied from. May be null.
      aFilter - The filter to be applied to check if the element should be added or not.
      aMapper - The mapping function to be executed for all provided elements. May not be null.
      Returns:
      The created array list. Never null.
      See Also:
    • createFiltered

      @Nonnull @ReturnsMutableCopy public static <SRCTYPE, ELEMENTTYPE> CommonsArrayList<ELEMENTTYPE> createFiltered(@Nullable Iterable<? extends SRCTYPE> aValues, @Nonnull Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper, @Nullable Predicate<? super ELEMENTTYPE> aFilter)
      Create a new array list that contains a subset of the provided iterable. This method maps the elements before they are filtered.
      Note: this method is a static factory method because the compiler sometimes cannot deduce between Predicate and Function and the mapping case occurs more often.
      Type Parameters:
      SRCTYPE - source data type
      ELEMENTTYPE - final data type of the list
      Parameters:
      aValues - The iterable from which the elements are copied from. May be null.
      aMapper - The mapping function to be executed for all provided elements. May not be null.
      aFilter - The filter to be applied on the mapped element to check if the element should be added or not.
      Returns:
      The created array list. Never null.
      Since:
      9.1.3
      See Also:
    • createFiltered

      @Nonnull @ReturnsMutableCopy public static <ELEMENTTYPE> CommonsArrayList<ELEMENTTYPE> createFiltered(@Nullable ELEMENTTYPE[] aValues, @Nullable Predicate<? super ELEMENTTYPE> aFilter)
      Create a new array list that contains a subset of the provided array.
      Note: this method is a static factory method because the compiler sometimes cannot deduce between Predicate and Function and the mapping case occurs more often.
      Type Parameters:
      ELEMENTTYPE - data type of the list
      Parameters:
      aValues - The array from which the elements are copied from. May be null.
      aFilter - The filter to be applied to check if the element should be added or not.
      Returns:
      The created array list. Never null.
      See Also:
    • createFiltered

      @Nonnull @ReturnsMutableCopy public static <SRCTYPE, ELEMENTTYPE> CommonsArrayList<ELEMENTTYPE> createFiltered(@Nullable SRCTYPE[] aValues, @Nullable Predicate<? super SRCTYPE> aFilter, @Nonnull Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper)
      Create a new array list that contains a subset of the provided array. This method filters the elements before they are mapped.
      Note: this method is a static factory method because the compiler sometimes cannot deduce between Predicate and Function and the mapping case occurs more often.
      Type Parameters:
      SRCTYPE - source data type
      ELEMENTTYPE - final data type of the list
      Parameters:
      aValues - The array from which the elements are copied from. May be null.
      aFilter - The filter to be applied to check if the element should be added or not.
      aMapper - The mapping function to be executed for all provided elements. May not be null.
      Returns:
      The created array list. Never null.
      See Also:
    • createFiltered

      @Nonnull @ReturnsMutableCopy public static <SRCTYPE, ELEMENTTYPE> CommonsArrayList<ELEMENTTYPE> createFiltered(@Nullable SRCTYPE[] aValues, @Nonnull Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper, @Nullable Predicate<? super ELEMENTTYPE> aFilter)
      Create a new array list that contains a subset of the provided array. This method maps the elements before they are filtered.
      Note: this method is a static factory method because the compiler sometimes cannot deduce between Predicate and Function and the mapping case occurs more often.
      Type Parameters:
      SRCTYPE - source data type
      ELEMENTTYPE - final data type of the list
      Parameters:
      aValues - The array from which the elements are copied from. May be null.
      aMapper - The mapping function to be executed for all provided elements. May not be null.
      aFilter - The filter to be applied on the mapped element to check if the element should be added or not.
      Returns:
      The created array list. Never null.
      Since:
      9.1.3
      See Also: