public class EntityCollectionDAO extends AbstractDataAccessObject implements Describable
A DAO backed by one or more collections of entities.
Modifier and Type | Method and Description |
---|---|
static EntityCollectionDAO |
create(java.util.Collection<? extends Entity> data)
Create a new event collection DAO.
|
static EntityCollectionDAO |
create(Entity... data)
Create a new event collection DAO.
|
void |
describeTo(DescriptionWriter writer)
Write this class’s description to a sink.
|
LongSet |
getEntityIds(EntityType type)
Get the IDs of all entities with a particular type.
|
java.util.Set<EntityType> |
getEntityTypes()
Get the types of entities that are available in this DAO.
|
Entity |
lookupEntity(EntityType type,
long id)
Look up an entity by ID.
|
<E extends Entity> |
lookupEntity(EntityType type,
long id,
java.lang.Class<E> view)
Look up an entity by ID and project it to a view class.
|
static EntityCollectionDAOBuilder |
newBuilder()
Create a new DAO builder.
|
<E extends Entity> |
streamEntities(EntityQuery<E> query)
Stream entities in response to a query.
|
ObjectStream<Entity> |
streamEntities(EntityType type)
Stream all entities of a particular type.
|
<E extends Entity> |
streamEntityGroups(EntityQuery<E> query,
TypedName<java.lang.Long> grpCol)
Stream entities in response to a query, grouping them by a long ID.
|
query, query
public static EntityCollectionDAOBuilder newBuilder()
Create a new DAO builder.
public static EntityCollectionDAO create(Entity... data)
Create a new event collection DAO.
data
- The data to store in the DAO.public static EntityCollectionDAO create(java.util.Collection<? extends Entity> data)
Create a new event collection DAO.
data
- The data to store in the DAO.public java.util.Set<EntityType> getEntityTypes()
DataAccessObject
Get the types of entities that are available in this DAO.
getEntityTypes
in interface DataAccessObject
public LongSet getEntityIds(EntityType type)
DataAccessObject
Get the IDs of all entities with a particular type.
getEntityIds
in interface DataAccessObject
type
- The entity type.@Nullable public Entity lookupEntity(EntityType type, long id)
DataAccessObject
Look up an entity by ID.
lookupEntity
in interface DataAccessObject
type
- The entity type.id
- The entity ID.null
if no such entity exists.@Nullable public <E extends Entity> E lookupEntity(EntityType type, long id, java.lang.Class<E> view)
DataAccessObject
Look up an entity by ID and project it to a view class.
lookupEntity
in interface DataAccessObject
type
- The entity type.id
- The entity ID.view
- The view class.null
if no such entity exists.public ObjectStream<Entity> streamEntities(EntityType type)
AbstractDataAccessObject
Stream all entities of a particular type.
This implementation delegates to DataAccessObject.streamEntities(EntityQuery)
streamEntities
in interface DataAccessObject
streamEntities
in class AbstractDataAccessObject
type
- The entity type.public <E extends Entity> ObjectStream<E> streamEntities(EntityQuery<E> query)
DataAccessObject
Stream entities in response to a query.
streamEntities
in interface DataAccessObject
query
- The query.public <E extends Entity> ObjectStream<IdBox<java.util.List<E>>> streamEntityGroups(EntityQuery<E> query, TypedName<java.lang.Long> grpCol)
AbstractDataAccessObject
Stream entities in response to a query, grouping them by a long ID.
This implementation delegates to AbstractDataAccessObject.streamEntities(EntityType)
and groups the result.
streamEntityGroups
in interface DataAccessObject
streamEntityGroups
in class AbstractDataAccessObject
query
- The query.grpCol
- The column to group by.public void describeTo(DescriptionWriter writer)
Describable
Write this class’s description to a sink. Anything relevant to this object’s identity should be digested; the idea is that, barring hash collisions, two objects with the same digest are equivalent. Used for things like deterministically generating cache file names.
describeTo
in interface Describable
writer
- The description writer to use.