public class AOPreloader<T extends LongEntity> extends Object
Modifier and Type | Field and Description |
---|---|
private com.atlassian.activeobjects.external.ActiveObjects |
ao |
private Class<T> |
clazz |
(package private) Map<Long,T> |
entityCache
Cache for AO entities, cached by ID.
|
private static int |
MAX_AO_ITEMS_IN_CACHE |
Constructor and Description |
---|
AOPreloader(com.atlassian.activeobjects.external.ActiveObjects ao,
Class<T> clazz) |
Modifier and Type | Method and Description |
---|---|
T |
getFullEntity(long id) |
T |
getFullEntity(T entity)
Returns a non-lazy-loaded entity.
|
List<T> |
getPreloadedValues(Predicate<T> predicate)
Filtering the cached values with the given predicate
|
void |
preloadAll(Collection<T> entities)
Preloads this list of entities, since we suspect we are going to need them quickly.
|
<U extends LongEntity> |
preloadAll(Collection<U> entities,
Function<U,T> getter,
BiConsumer<U,T> setter)
Preloads all entities which are inside the records of the list passed in parameter.
|
void |
preloadAll(Set<Long> ids) |
void |
putCachedEntities(List<T> entities) |
void |
putCachedEntity(T entity)
If we retrieve some interesting entity which might be reused later, this method puts it in the cache
|
int |
size()
Returns the number of preloaded items
|
private static final int MAX_AO_ITEMS_IN_CACHE
private final com.atlassian.activeobjects.external.ActiveObjects ao
private final Class<T extends LongEntity> clazz
final Map<Long,T extends LongEntity> entityCache
public void preloadAll(Collection<T> entities)
entities
- the list of entities to preload. Those entities generally have been lazy-loaded, their fields
aren't present.public <U extends LongEntity> void preloadAll(Collection<U> entities, Function<U,T> getter, BiConsumer<U,T> setter)
preloader.preloadAll(dbLinks, DBLink::getParent, DBLink::setParent);
Warning: This calls .set on the entities.public T getFullEntity(T entity)
public void putCachedEntity(T entity)
public List<T> getPreloadedValues(@Nonnull Predicate<T> predicate)
public int size()
Copyright © 2022 Requirement Yogi. All rights reserved.