Class NamedArrayList<E>

Type Parameters:
E - the type of element.
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, RandomAccess

public class NamedArrayList<E> extends ArrayList<E>
An ArrayList that also has an associated name for use with the FormTagLib.traits() tag.
See Also:
  • Constructor Details

    • NamedArrayList

      public NamedArrayList(@NonNull String name, Collection<? extends E> c)
      Copy constructor.
      Parameters:
      name - the name.
      c - the collection whose elements are to be placed into this list
    • NamedArrayList

      public NamedArrayList(@NonNull String name, E... elements)
      Copy constructor.
      Parameters:
      name - the name.
      elements - the initial elements.
  • Method Details

    • getName

      @NonNull public final String getName()
      Gets the associate name.
      Returns:
      the associate name.
    • select

      public static <E> void select(@NonNull List<? extends E> source, @NonNull String name, @CheckForNull NamedArrayList.Predicate<? super E> selector, boolean removeSelectedFromSource, @NonNull List<NamedArrayList<? extends E>> destination)
      Helper method that creates a new NamedArrayList by selecting matching elements from a source list and appends the new NamedArrayList to a list of NamedArrayList.
      Type Parameters:
      E - the type of element.
      Parameters:
      source - the list of candidate elements.
      name - the name.
      selector - the (optional) selection criteria (if null then all candidate elements will be added)
      removeSelectedFromSource - if true then the matching elements will be removed from the source.
      destination - the List of NamedArrayList to add to (empty selections will not be added)
    • select

      public static <E> void select(@NonNull List<? extends E> source, @NonNull String name, @CheckForNull NamedArrayList.Predicate<? super E> selector, boolean removeSelectedFromSource, @NonNull List<NamedArrayList<? extends E>> destination, int index)
      Helper method that creates a new NamedArrayList by selecting matching elements from a source list and appends the new NamedArrayList to a list of NamedArrayList.
      Type Parameters:
      E - the type of element.
      Parameters:
      source - the list of candidate elements.
      name - the name.
      selector - the (optional) selection criteria (if null then all candidate elements will be added)
      removeSelectedFromSource - if true then the matching elements will be removed from the source.
      destination - the List of NamedArrayList to add to (empty selections will not be added)
      index - index at which the specified selection is to be inserted (will be coerced into the valid range to remove the risk of IndexOutOfBoundsException).
    • allOf

      public static <E> NamedArrayList.Predicate<E> allOf(NamedArrayList.Predicate<? super E>... predicates)
      Combines NamedArrayList.Predicate instances using a boolean short-circuit logical AND.
      Type Parameters:
      E - type.
      Parameters:
      predicates - the predicates to combine.
      Returns:
      a composite predicate.
    • anyOf

      public static <E> NamedArrayList.Predicate<E> anyOf(NamedArrayList.Predicate<E>... predicates)
      Combines NamedArrayList.Predicate instances using a boolean short-circuit logical OR.
      Type Parameters:
      E - type.
      Parameters:
      predicates - the predicates to combine.
      Returns:
      a composite predicate.
    • withAnnotation

      public static <A extends Annotation> NamedArrayList.Predicate<Object> withAnnotation(Class<A> annotation)
      Returns a NamedArrayList.Predicate that checks if the object class has been annotated with the supplied annotation.
      Type Parameters:
      A - the type of annotation.
      Parameters:
      annotation - the annotation to check.
      Returns:
      the predicate.