Module jonix.common

Class ListOfOnixComposite<C extends OnixComposite>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<C>
com.tectonica.jonix.common.ListOfOnixComposite<C>
All Implemented Interfaces:
Serializable, Cloneable, Iterable<C>, Collection<C>, List<C>, RandomAccess

public class ListOfOnixComposite<C extends OnixComposite> extends ArrayList<C>
See Also:
  • Method Details

    • itemClass

      public Class<C> itemClass()
      Returns:
      the Class of the items in this List
    • first

      public Optional<C> first()
      Returns:
      an Optional of the first OnixComposite listed, if any
    • firstOrEmpty

      public C firstOrEmpty()
      Returns:
      the first OnixComposite listed, if any, or an "empty" instance (whose OnixTag.exists() is false), which can be further traversed by your code (as if it exists in the ONIX source), with all underlying data fields eventually yielding "non-existing" value
    • filter

      public ListOfOnixComposite<C> filter(Predicate<C> predicate)
      Given this list of OnixComposites, this method creates a new list containing only a subset of items, or none, conforming to the condition passed in the Predicate object.

      Note that this method is different from .stream().filter() in that it returns a list of the same original type (i.e. ListOfOnixComposite), and not a generic Java List. This allows the caller to apply methods such as firstOrEmpty() on the returned list.

      Returns:
      a non-null, possibly empty, sublist of items meeting the predicate condition