public final class PrefetchingUserEventDAO extends Object implements UserEventDAO, Describable
User event DAO that pre-loads all events from an event DAO.
Constructor and Description |
---|
PrefetchingUserEventDAO(EventDAO dao) |
Modifier and Type | Method and Description |
---|---|
void |
describeTo(DescriptionWriter writer)
Write this class’s description to a sink.
|
UserHistory<Event> |
getEventsForUser(long user)
Get the events for a specific user.
|
<E extends Event> |
getEventsForUser(long user,
Class<E> type)
Get the events for a specific user, filtering by type.
|
ObjectStream<UserHistory<Event>> |
streamEventsByUser()
Stream events grouped by user.
|
<E extends Event> |
streamEventsByUser(Class<E> type)
Stream events grouped by user.
|
static Function<EventDAO,UserEventDAO> |
wrapper()
A function that wraps an event DAO in a prefetching user event DAO.
|
@Inject public PrefetchingUserEventDAO(EventDAO dao)
public static Function<EventDAO,UserEventDAO> wrapper()
A function that wraps an event DAO in a prefetching user event DAO. If the DAO already implements UserEventDAO
, it is returned unwrapped.
public ObjectStream<UserHistory<Event>> streamEventsByUser()
UserEventDAO
Stream events grouped by user.
streamEventsByUser
in interface UserEventDAO
public <E extends Event> ObjectStream<UserHistory<E>> streamEventsByUser(Class<E> type)
UserEventDAO
Stream events grouped by user.
streamEventsByUser
in interface UserEventDAO
type
- The type of item to look for.type
. If a user exists, but does not have any history, they may or may not be included depending on the DAO implementation.public UserHistory<Event> getEventsForUser(long user)
UserEventDAO
Get the events for a specific user.
getEventsForUser
in interface UserEventDAO
user
- The user ID.null
if the user is unknown.public <E extends Event> UserHistory<E> getEventsForUser(long user, Class<E> type)
UserEventDAO
Get the events for a specific user, filtering by type.
getEventsForUser
in interface UserEventDAO
user
- The user ID.type
- The type of events to retrieve.null
if the user is unknown.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.