E - the type of entities being stored in this listL - the effective subclass used as fluent return typepublic abstract class BaseEntityRefList<E extends BaseEntity<String>,L extends BaseEntityRefList<E,L>> extends SafeList<String>
BaseEntity.
The main benefit over simply using a plain StringList is the referential integrity provided via the given
delete handler.
| Modifier and Type | Field and Description |
|---|---|
protected BaseEntityRef.OnDelete |
deleteHandler |
protected Class<E> |
type |
| Modifier | Constructor and Description |
|---|---|
protected |
BaseEntityRefList(Class<E> type,
BaseEntityRef.OnDelete deleteHandler) |
| Modifier and Type | Method and Description |
|---|---|
L |
add(E entity)
Adds the given entity to the list.
|
boolean |
contains(E entity)
Determines if the given entity is in the list.
|
protected String |
copyValue(String value)
Creates a copy of the given value.
|
Stream<Optional<E>> |
fetchAll(ContextInfo... context)
Retruns all entity in the list by resolving them against the database.
|
Stream<E> |
fetchAllAvailable(ContextInfo... context)
Retruns all entity in the list by resolving them against the database.
|
BaseEntityRef.OnDelete |
getDeleteHandler()
Returns the delete handler to use.
|
Class<E> |
getType()
Returns the underlying entity type.
|
L |
remove(E entity)
Removes the given entity from the list.
|
protected abstract Optional<E> |
resolve(String id,
ContextInfo... context)
Resolves a given ID into an entity instance.
|
protected boolean |
valueNeedsCopy()
Determines if values in this list must be copied if the list is copied.
|
protected BaseEntityRef.OnDelete deleteHandler
protected Class<E extends BaseEntity<String>> type
protected BaseEntityRefList(Class<E> type, BaseEntityRef.OnDelete deleteHandler)
protected abstract Optional<E> resolve(String id, ContextInfo... context)
id - the id to resolvecontext - the context used for resolving (routing etc.)public L add(E entity)
If the entity is null or new, nothing will happen.
entity - the entity to addpublic L remove(E entity)
If the entity is null or new, nothing will happen.
entity - the entity to removepublic boolean contains(E entity)
entity - the entity to check for.public Stream<Optional<E>> fetchAll(ContextInfo... context)
This will perform N uncached lookups against the database - use with caution.
context - the lookup contextpublic Stream<E> fetchAllAvailable(ContextInfo... context)
This will perform N uncached lookups against the database - use with caution.
context - the lookup contextprotected boolean valueNeedsCopy()
SafeListvalueNeedsCopy in class SafeList<String>protected String copyValue(String value)
SafeListpublic BaseEntityRef.OnDelete getDeleteHandler()
Copyright © 2018. All rights reserved.