Class SingletonEntityList
java.lang.Object
ch.tocco.nice2.persist.core.api.util.SingletonEntityList
- All Implemented Interfaces:
EntityList, Iterable<Entity>
-
Nested Class Summary
Nested classes/interfaces inherited from interface EntityList
EntityList.Filter -
Constructor Summary
ConstructorsConstructorDescriptionSingletonEntityList(Entity entity) SingletonEntityList(Entity entity, EntityManager manager) -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(PrimaryKey key) 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.get(int index, boolean eager) Get the entity at the specified index.get(PrimaryKey key) Get the entity with the specified key in that list with eager loading.get(PrimaryKey key, boolean eager) Get the entity with the specified key in that list.getKey(int index) Returns the PrimaryKey at the specified position.getKeys()Read in subclasses if this array can contain null values or not.Get the entity manager.getModel()Get the model of the entity type contained in this list.intGet the number of pages in this list.intGet the current page size.intindexOf(PrimaryKey key) Get the index within the list of the entity with the specified key.booleanisEmpty()Same as size() == 0iterator()voidsetPageSize(int pageSize) Set the page size.intsize()Get the number of entities this list contains.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.unwrap()Unwrap to the underlying entity list.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EntityList
doWithSingleResult, doWithSingleResultOr, expectAtMostOrThrow, expectOr, expectOrThrow, getFirstEntity, getOnlyResult, getOptionalOnlyResult, getOptionalOnlyResult, requireFirstEntity, spliterator, stream
-
Constructor Details
-
SingletonEntityList
-
SingletonEntityList
-
-
Method Details
-
size
public int size()Description copied from interface:EntityListGet the number of entities this list contains.- Specified by:
sizein interfaceEntityList- Returns:
- The number of entities.
-
isEmpty
public boolean isEmpty()Description copied from interface:EntityListSame as size() == 0- Specified by:
isEmptyin interfaceEntityList- Returns:
- If the list is empty.
-
getKeys
Description copied from interface:EntityListRead in subclasses if this array can contain null values or not.- Specified by:
getKeysin interfaceEntityList- Returns:
- A defensive copy of the array. The size matches the
EntityList.size()method.
-
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. - Throws:
PersistException
-
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. - Throws:
PersistException- See Also:
-
get
Description copied from interface:EntityListGet the entity at the specified index.- Specified by:
getin interfaceEntityList- Parameters:
index- The index.eager-true, if a page should be eagerly loaded, if the entity's state ishollow, false otherwise.- Returns:
- The entity at the specified index potentially in
unusable state, ornull. - Throws:
PersistException
-
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. - Throws:
PersistException
-
toList
Description copied from interface:EntityListReturns the Entities of this list in a List using eager loading.- Specified by:
toListin interfaceEntityList- Throws:
PersistException
-
toList
Description copied from interface:EntityListReturns the Entities of this list in a List using eager loading.- Specified by:
toListin interfaceEntityList- Throws:
PersistException
-
getKey
Description copied from interface:EntityListReturns the PrimaryKey at the specified position.- Specified by:
getKeyin interfaceEntityList
-
indexOf
Description copied from interface:EntityListGet the index within the list of the entity with the specified key.- Specified by:
indexOfin interfaceEntityList- Parameters:
key- The primary key.- Returns:
- The index or -1, if there's no such entity in the list.
-
contains
Description copied from interface:EntityListDetermine, whether the list contains an entity with the specified key.- Specified by:
containsin interfaceEntityList- Parameters:
key- The primary key.- Returns:
true, if there's an entity with the specified key,falseotherwise.
-
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.
- Throws:
PermanentPersistException- 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.
- Throws:
PermanentPersistException- 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.
- Throws:
PermanentPersistException- See Also:
-
getModel
Description copied from interface:EntityListGet the model of the entity type contained in this list.- Specified by:
getModelin interfaceEntityList- Returns:
- The model of the entity type contained in this list.
-
getManager
Description copied from interface:EntityListGet the entity manager.- Specified by:
getManagerin interfaceEntityList- Returns:
- The entity manager.
-
unwrap
Description copied from interface:EntityListUnwrap to the underlying entity list. Wrappers of entity lists should delegate this to the list they're wrapping, implementations returnthis. It may be that they cannot, and then return themselves (MultiEntityList).- Specified by:
unwrapin interfaceEntityList- Returns:
- The underlying entity list implementation.
-
setPageSize
public void setPageSize(int pageSize) Description copied from interface:EntityListSet the page size. The page size determines how many objects will be loaded, once ahollowentity has been accessed.- Specified by:
setPageSizein interfaceEntityList- Parameters:
pageSize- The new page size.
-
getPageSize
public int getPageSize()Description copied from interface:EntityListGet the current page size.- Specified by:
getPageSizein interfaceEntityList- Returns:
- The current page size.
-
getPageCount
public int getPageCount()Description copied from interface:EntityListGet the number of pages in this list.- Specified by:
getPageCountin interfaceEntityList- Returns:
- The number of pages in this list
(
size/pageSize + (size%pageSize>0 ? 1 : 0)).
-
iterator
-