public abstract class EntityCollection extends java.util.AbstractCollection<Entity>
A collection of entities of a single type. This collection augments the Collection
interface with logic for different kinds of (possibly optimized) entity searches.
Modifier and Type | Method and Description |
---|---|
abstract <T> java.util.List<Entity> |
find(Attribute<T> attr)
Find entities with an attribute.
|
abstract java.util.List<Entity> |
find(java.lang.String name,
java.lang.Object value)
Find entities by attribute.
|
abstract <T> java.util.List<Entity> |
find(TypedName<T> name,
T value)
Find entities by attribute.
|
java.util.List<SortKey> |
getSortKeys()
Get the sort keys, if this collection stores attributes in sorted order.
|
abstract EntityType |
getType()
Get the type of entity stored in this collection.
|
abstract java.util.Map<java.lang.Long,java.util.List<Entity>> |
grouped(TypedName<java.lang.Long> attr)
Get a grouped view of the data.
|
abstract LongSet |
idSet() |
abstract Entity |
lookup(long id)
Look up an entity by ID.
|
static EntityCollectionBuilder |
newBareBuilder(EntityType type)
Create a new builder for colletions of bare entitites (only storing IDs).
|
static EntityCollectionBuilder |
newBuilder(EntityType type)
Create a new entity collection builder.
|
static EntityCollectionBuilder |
newBuilder(EntityType type,
AttributeSet attrs)
Create a new packed entity collection builder.
|
static EntityCollectionBuilder |
newBuilder(EntityType type,
AttributeSet attrs,
java.lang.Class<? extends EntityBuilder> eb)
Create a new packed entity collection builder.
|
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public static EntityCollectionBuilder newBuilder(EntityType type)
Create a new entity collection builder.
public static EntityCollectionBuilder newBuilder(EntityType type, AttributeSet attrs)
Create a new packed entity collection builder.
type
- The entity type.attrs
- The attributes to store.public static EntityCollectionBuilder newBuilder(EntityType type, AttributeSet attrs, java.lang.Class<? extends EntityBuilder> eb)
Create a new packed entity collection builder.
type
- The entity type.attrs
- The attributes to store.eb
- An entity builder to use when reconstituting entities.public static EntityCollectionBuilder newBareBuilder(EntityType type)
Create a new builder for colletions of bare entitites (only storing IDs).
type
- The entity type.public abstract EntityType getType()
Get the type of entity stored in this collection.
public abstract LongSet idSet()
@Nullable public abstract Entity lookup(long id)
Look up an entity by ID.
id
- The entity ID.null
if no such entity exists.@Nonnull public abstract <T> java.util.List<Entity> find(TypedName<T> name, T value)
Find entities by attribute.
name
- The attribute name.value
- The attribute value.name
has value value
.@Nonnull public abstract <T> java.util.List<Entity> find(Attribute<T> attr)
Find entities with an attribute.
attr
- The attribute to look for.T
- The attribute type.@Nonnull public abstract java.util.List<Entity> find(java.lang.String name, java.lang.Object value)
Find entities by attribute.
name
- The attribute name.value
- The attribute value.name
has value value
.public abstract java.util.Map<java.lang.Long,java.util.List<Entity>> grouped(TypedName<java.lang.Long> attr)
Get a grouped view of the data.
attr
- The grouping attribute.public java.util.List<SortKey> getSortKeys()
Get the sort keys, if this collection stores attributes in sorted order.