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
Abstract
EntityList
base class that implements common functions.-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.tocco.nice2.persist.core.api.entity.EntityList
EntityList.Filter
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(PrimaryKey pk) Determine, whether the list contains an entity with the specified key.expect
(int amount) Throws if the list does not contain exactly that amount.expectAtLeast
(int min) Throws if the list contains fewer than min items.expectAtMost
(int max) Throws if the list contains more than max items.get
(int index) Get the entity at the specified index with eager loading.@Nullable Entity
get
(PrimaryKey key) Get the entity with the specified key in that list with eager loading.@Nullable Entity
get
(PrimaryKey key, boolean eager) Get the entity with the specified key in that list.boolean
isEmpty()
Same as size() == 0iterator()
toList()
Returns the Entities of this list in a List using eager loading.Returns the Entities of this list in a List using eager loading.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ch.tocco.nice2.persist.core.api.entity.EntityList
doWithSingleResult, doWithSingleResultOr, expectAtMostOrThrow, expectOr, expectOrThrow, get, getFirstEntity, getKey, getKeys, getManager, getModel, getOnlyResult, getOptionalOnlyResult, getOptionalOnlyResult, getPageCount, getPageSize, indexOf, requireFirstEntity, setPageSize, size, spliterator, stream, unwrap
-
Constructor Details
-
AbstractEntityList
public AbstractEntityList()
-
-
Method Details
-
isEmpty
public boolean isEmpty()Description copied from interface:EntityList
Same as size() == 0- Specified by:
isEmpty
in interfaceEntityList
- Returns:
- If the list is empty.
-
contains
Description copied from interface:EntityList
Determine, whether the list contains an entity with the specified key.- Specified by:
contains
in interfaceEntityList
- Parameters:
pk
- The primary key.- Returns:
true
, if there's an entity with the specified key,false
otherwise.
-
get
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 interfaceEntityList
- Parameters:
index
- The index.- Returns:
- The entity at the specified index potentially in
unusable state
, ornull
.
-
get
Description copied from interface:EntityList
Get the entity with the specified key in that list with eager loading.- Specified by:
get
in interfaceEntityList
- Returns:
- The entity potentially in
unusable state
, ornull
. - See Also:
-
get
Description copied from interface:EntityList
Get the entity with the specified key in that list.- Specified by:
get
in interfaceEntityList
- Parameters:
key
- The key of the entity.eager
-true
, if a page should be eagerly loaded, if the entity's state ishollow
, false otherwise.- Returns:
- The entity with the specified key potentially in
unusable state
, ornull
.
-
toList
Description copied from interface:EntityList
Returns the Entities of this list in a List using eager loading.- Specified by:
toList
in interfaceEntityList
-
toList
Description copied from interface:EntityList
Returns the Entities of this list in a List using eager loading.- Specified by:
toList
in interfaceEntityList
-
expect
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 interfaceEntityList
- Parameters:
amount
- The expected amount.- Returns:
- The list itself.
- See Also:
-
expectAtLeast
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 interfaceEntityList
- Parameters:
min
- The expected minimal amount, including.- Returns:
- The list itself.
- See Also:
-
expectAtMost
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 interfaceEntityList
- Parameters:
max
- The expected maximal amount, including.- Returns:
- The list itself.
- See Also:
-
iterator
-