Class AbstractEntityList

java.lang.Object
ch.tocco.nice2.persist.core.api.entity.AbstractEntityList
All Implemented Interfaces:
EntityList, Iterable<Entity>
Direct Known Subclasses:
AbstractEntityListWrapper, AbstractLazyEntityList, AbstractRelationAdapter, EmptyEntityList, EntityListImpl, MultiEntityList, OffsetEntityList, PrimaryKeyEntityList

public abstract class AbstractEntityList extends Object implements EntityList
Abstract EntityList base class that implements common functions.
  • Constructor Details

    • AbstractEntityList

      public AbstractEntityList()
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Description copied from interface: EntityList
      Same as size() == 0
      Specified by:
      isEmpty in interface EntityList
      Returns:
      If the list is empty.
    • contains

      public boolean contains(PrimaryKey pk)
      Description copied from interface: EntityList
      Determine, whether the list contains an entity with the specified key.
      Specified by:
      contains in interface EntityList
      Parameters:
      pk - The primary key.
      Returns:
      true, if there's an entity with the specified key, false otherwise.
    • get

      public Entity get(int index)
      Description copied from interface: EntityList
      Get the entity at the specified index with eager loading.

      This method will load a full page if the entity is currently hollow.

      Specified by:
      get in interface EntityList
      Parameters:
      index - The index.
      Returns:
      The entity at the specified index potentially in unusable state, or null.
    • get

      @Nullable public @Nullable Entity get(PrimaryKey key)
      Description copied from interface: EntityList
      Get the entity with the specified key in that list with eager loading.
      Specified by:
      get in interface EntityList
      Returns:
      The entity potentially in unusable state, or null.
      See Also:
    • get

      @Nullable public @Nullable Entity get(PrimaryKey key, boolean eager)
      Description copied from interface: EntityList
      Get the entity with the specified key in that list.
      Specified by:
      get in interface EntityList
      Parameters:
      key - The key of the entity.
      eager - true, if a page should be eagerly loaded, if the entity's state is hollow, false otherwise.
      Returns:
      The entity with the specified key potentially in unusable state, or null.
    • toList

      public List<Entity> toList()
      Description copied from interface: EntityList
      Returns the Entities of this list in a List using eager loading.
      Specified by:
      toList in interface EntityList
    • toList

      public List<Entity> toList(Predicate<Entity> filter)
      Description copied from interface: EntityList
      Returns the Entities of this list in a List using eager loading.
      Specified by:
      toList in interface EntityList
    • expect

      public EntityList expect(int amount)
      Description copied from interface: EntityList
      Throws if the list does not contain exactly that amount.

      Example: EntityList entityList = myQuery.execute(1).expect(1);

      Specified by:
      expect in interface EntityList
      Parameters:
      amount - The expected amount.
      Returns:
      The list itself.
      See Also:
    • expectAtLeast

      public EntityList expectAtLeast(int min)
      Description copied from interface: EntityList
      Throws if the list contains fewer than min items.

      Example: EntityList entityList = myQuery.execute().expectAtLeast(3);

      Specified by:
      expectAtLeast in interface EntityList
      Parameters:
      min - The expected minimal amount, including.
      Returns:
      The list itself.
      See Also:
    • expectAtMost

      public EntityList expectAtMost(int max)
      Description copied from interface: EntityList
      Throws if the list contains more than max items.

      Example: EntityList entityList = myQuery.execute(3).expectAtMost(3);

      Specified by:
      expectAtMost in interface EntityList
      Parameters:
      max - The expected maximal amount, including.
      Returns:
      The list itself.
      See Also:
    • iterator

      public Iterator<Entity> iterator()
      Specified by:
      iterator in interface Iterable<Entity>