Module jonix.common

Class ListOfOnixDataComposite<C extends OnixComposite.OnixDataComposite<S>,S extends JonixStruct>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<C>
com.tectonica.jonix.common.ListOfOnixDataComposite<C,S>
All Implemented Interfaces:
Serializable, Cloneable, Iterable<C>, Collection<C>, List<C>, RandomAccess
Direct Known Subclasses:
ListOfOnixDataCompositeWithKey

public class ListOfOnixDataComposite<C extends OnixComposite.OnixDataComposite<S>,S extends JonixStruct> extends ArrayList<C>
See Also:
  • Constructor Details

    • ListOfOnixDataComposite

      public ListOfOnixDataComposite(Class<C> clazz)
  • Method Details

    • itemClass

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

      public List<S> asStructs()
      returns a list of the items inside this list, transformed into Jonix structs
      Returns:
      a non-null, possibly empty, list of the structs
    • structsInto

      public <L extends Collection<S>> L structsInto(L collection)
    • first

      public Optional<C> first()
    • firstAsStruct

      public Optional<S> firstAsStruct()
    • firstOrEmpty

      public C firstOrEmpty()
      Returns:
      the first OnixComposite.OnixDataComposite 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
    • firstOrEmptyAsStruct

      public S firstOrEmptyAsStruct()
      Returns:
      same as firstOrEmpty() but wraps this OnixComposite.OnixDataComposite as a JonixStruct
    • filter

      public ListOfOnixDataComposite<C,S> filter(Predicate<C> predicate)
      Given this list of OnixComposite.OnixDataComposites, 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. ListOfOnixDataComposite), 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