com.ibm.commerce.price.utils

Class MixList<T>

  • java.lang.Object
    • java.util.AbstractCollection<E>
      • java.util.AbstractList<E>
        • java.util.ArrayList<T>
          • com.ibm.commerce.price.utils.MixList<T>
  • Type Parameters:
    T - The type of the elements in the list.
    All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.List<T>, java.util.RandomAccess


    public class MixList<T>
    extends java.util.ArrayList<T>
    MixList is a List that has better support for arrays. It is useful for maintaining a list internally but converting to arrays and back.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      MixList(java.lang.Class<T> newType)
      Constructor for MixList with the given element type.
      MixList(java.lang.Class<T> newType, int capacity)
      Constructor for MixList with the given element type.
      MixList(java.lang.Class<T> newType, java.util.List items)
      Constructor for MixList with the given element type and array.
      MixList(java.lang.Class<T> newType, T[] items)
      Constructor for MixList with the given element type and array.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addAll(T[] items)
      Adds all elements in the given array to this.
      T[] asArray()
      Returns the elements in this as an array.
      void copyToArray(T[] items)
      Copies the elements from this to the given array.
      static <T> T[] createArray(MixList<T> items)
      Convenience method which lets a null list pass through or converts it to an array otherwise.
      static <T> T[] createArray(T... items)
      Convenience method which creates an array out of the objects given.
      static <T> MixList<T> createList(T... items)
      Factory method for creating a list from several items or an array of items without having to specify the class.
      • Methods inherited from class java.util.ArrayList

        add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
      • Methods inherited from class java.util.AbstractList

        equals, hashCode
      • Methods inherited from class java.util.AbstractCollection

        containsAll, toString
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.List

        containsAll, equals, hashCode
      • Methods inherited from interface java.util.Collection

        parallelStream, stream
    • Constructor Detail

      • MixList

        public MixList(java.lang.Class<T> newType)
        Constructor for MixList with the given element type.
        Parameters:
        newType - The type of elements in the new list. Cannot be null.
      • MixList

        public MixList(java.lang.Class<T> newType,
                       int capacity)
        Constructor for MixList with the given element type.
        Parameters:
        newType - The type of elements in the new list. Cannot be null.
        capacity - the initial capacity of this ArrayList
      • MixList

        public MixList(java.lang.Class<T> newType,
                       java.util.List items)
        Constructor for MixList with the given element type and array.
        Parameters:
        newType - The type of elements in the new list. Cannot be null.
        items - The items to initially populate the list with. May be null or empty.
      • MixList

        public MixList(java.lang.Class<T> newType,
                       T[] items)
        Constructor for MixList with the given element type and array.
        Parameters:
        newType - The type of elements in the new list. Cannot be null.
        items - The items to initially populate the list with. May be null or empty.
    • Method Detail

      • addAll

        public final void addAll(T[] items)
        Adds all elements in the given array to this.
        Parameters:
        items - Adds all the elements in the array to this. Cannot be null, but may be empty.
      • asArray

        public T[] asArray()
        Returns the elements in this as an array. Modifications to the returned array will not change the elements in this.
        Returns:
        An array with the same elements as in this. This array will not be null, but may be empty if this contains no elements.
      • copyToArray

        public final void copyToArray(T[] items)
        Copies the elements from this to the given array.
        Parameters:
        items - The array which will have its elements overwritten. Cannot be null, and its length must be equal to a call from List.size(). The given array may only be empty if this has no elements.
      • createArray

        public static <T> T[] createArray(MixList<T> items)
        Convenience method which lets a null list pass through or converts it to an array otherwise. This is useful if the list itself can be null.
        Type Parameters:
        T - The type of the input and output elements.
        Parameters:
        items - The items to form the array. If null or empty, the returned array will be the same.
        Returns:
        The output array. This value will be null or empty as the input list is null or empty.
      • createArray

        public static <T> T[] createArray(T... items)
        Convenience method which creates an array out of the objects given. This is useful for ECTrace.entry(long, String, String, Object[]) method calls.
        Type Parameters:
        T - The type of the input and output elements.
        Parameters:
        items - The items to be put in the array. If null or empty, the same will be returned.
        Returns:
        The output array. This value will be null or empty as the input is null or empty.
      • createList

        public static <T> MixList<T> createList(T... items)
        Factory method for creating a list from several items or an array of items without having to specify the class.
        Type Parameters:
        T - The type of the elements in the list and array.
        Parameters:
        items - The items to put in the array. If null, null will be returned.
        Returns:
        A list with the same type of elements in the array. Will be null if the input is a null array.