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 ClassesNested classes/interfaces inherited from interface ch.tocco.nice2.persist.core.api.entity.EntityList
EntityList.Filter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(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 Entityget(PrimaryKey key) Get the entity with the specified key in that list with eager loading.@Nullable Entityget(PrimaryKey key, boolean eager) Get the entity with the specified key in that list.booleanisEmpty()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, waitMethods 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:EntityListSame as size() == 0- Specified by:
isEmptyin interfaceEntityList- Returns:
- If the list is empty.
-
contains
Description copied from interface:EntityListDetermine, whether the list contains an entity with the specified key.- Specified by:
containsin interfaceEntityList- Parameters:
pk- The primary key.- Returns:
true, if there's an entity with the specified key,falseotherwise.
-
get
Description copied from interface:EntityListGet the entity at the specified index with eager loading.This method will load a full page if the entity is currently
hollow.- Specified by:
getin interfaceEntityList- Parameters:
index- The index.- Returns:
- The entity at the specified index potentially in
unusable state, ornull.
-
get
Description copied from interface:EntityListGet the entity with the specified key in that list with eager loading.- Specified by:
getin interfaceEntityList- Returns:
- The entity potentially in
unusable state, ornull. - See Also:
-
get
Description copied from interface:EntityListGet the entity with the specified key in that list.- Specified by:
getin 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:EntityListReturns the Entities of this list in a List using eager loading.- Specified by:
toListin interfaceEntityList
-
toList
Description copied from interface:EntityListReturns the Entities of this list in a List using eager loading.- Specified by:
toListin interfaceEntityList
-
expect
Description copied from interface:EntityListThrows if the list does not contain exactly that amount.Example:
EntityList entityList = myQuery.execute(1).expect(1);- Specified by:
expectin interfaceEntityList- Parameters:
amount- The expected amount.- Returns:
- The list itself.
- See Also:
-
expectAtLeast
Description copied from interface:EntityListThrows if the list contains fewer than min items.Example:
EntityList entityList = myQuery.execute().expectAtLeast(3);- Specified by:
expectAtLeastin interfaceEntityList- Parameters:
min- The expected minimal amount, including.- Returns:
- The list itself.
- See Also:
-
expectAtMost
Description copied from interface:EntityListThrows if the list contains more than max items.Example:
EntityList entityList = myQuery.execute(3).expectAtMost(3);- Specified by:
expectAtMostin interfaceEntityList- Parameters:
max- The expected maximal amount, including.- Returns:
- The list itself.
- See Also:
-
iterator
-