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(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.
|
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,
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.
|
query, query, streamEntityGroups
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(Collection<? extends Entity> data)
Create a new event collection DAO.
data
- The data to store in the DAO.public 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, 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 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.