Package com.storedobject.core
Class ObjectCache<T extends StoredObject>
java.lang.Object
com.storedobject.core.ObjectCache<T>
- All Implemented Interfaces:
FilterMethods<T>,ObjectLoader<T>,Iterable<T>
public class ObjectCache<T extends StoredObject>
extends Object
implements Iterable<T>, ObjectLoader<T>
-
Constructor Summary
ConstructorsConstructorDescriptionObjectCache(Class<T> objectClass) ObjectCache(Class<T> objectClass, boolean any) ObjectCache(Class<T> objectClass, ObjectIterator<T> objects) ObjectCache(Class<T> objectClass, Query query) ObjectCache(Class<T> objectClass, Query query, boolean any) ObjectCache(Class<T> objectClass, Iterable<Id> idList) ObjectCache(Class<T> objectClass, String condition) ObjectCache(Class<T> objectClass, String condition, boolean any) ObjectCache(Class<T> objectClass, String condition, String orderedBy) ObjectCache(Class<T> objectClass, String condition, String orderedBy, boolean any) ObjectCache(Class<T> objectClass, Stream<T> objects) -
Method Summary
Modifier and TypeMethodDescriptionvoidThis method is called whenever a filter predicate is changed.voidclose()booleanbooleanget(int index) intintgetId(int index) Get the load filter.The class of the instances.idStream(int startingIndex, int endingIndex) intintiterator()list()list(int startingIndex) list(int startingIndex, int endingIndex) listIds()listIds(int startingIndex) listIds(int startingIndex, int endingIndex) voidload(int linkType, StoredObject master, String condition, String orderedBy, boolean any) Load the links of the given "master" instance.voidload(ObjectIterator<T> objects) Load the given instances.voidLoad the instances created from the query.voidLoad the instances created from the list ofIds.voidLoad the instances.voidLoad the given instances.loop()loop(int startingIndex) loop(int startingIndex, int endingIndex) loopIds()loopIds(int startingIndex) loopIds(int startingIndex, int endingIndex) voidvoidrefresh()voidvoidfinal voidsetAllowAny(boolean any) voidsetCacheSize(int size) voidsetProcessor(Consumer<T> processor) intsize()Get the instances count.intsize(int startingIndex, int endingIndex) sort(Comparator<? super T> comparator) stream(int startingIndex, int endingIndex) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.storedobject.core.FilterMethods
getEffectiveCondition, getFilterCondition, setFilter, setFilter, setFilter, setFilter, setFilter, setFilter, setLoadFilter, setLoadFilter, setViewFilter, setViewFilterMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface com.storedobject.core.ObjectLoader
applyFilter, canContain, clear, getAllowAny, getLinkType, getMaster, getOrderBy, isAllowAny, load, load, load, load, load, load, load, load, load, load, load, load, load, load, load, load, load, reload, setLinkType, setLinkType, setMaster, setMaster, setOrderBy, setOrderBy
-
Constructor Details
-
ObjectCache
-
ObjectCache
-
ObjectCache
-
ObjectCache
-
ObjectCache
-
ObjectCache
-
ObjectCache
-
ObjectCache
-
ObjectCache
-
ObjectCache
-
ObjectCache
-
-
Method Details
-
setProcessor
-
load
Description copied from interface:ObjectLoaderLoad the instances. Current "load filter" if set will be applied. If "master" is already set, "links" of the "master" will be loaded.- Specified by:
loadin interfaceObjectLoader<T extends StoredObject>- Parameters:
condition- Filtering condition to be applied.orderedBy- "ORDER BY" clause to use while loading.any- Whether instanced of the subclasses to be retrieved or not.
-
load
public void load(int linkType, StoredObject master, String condition, String orderedBy, boolean any) Description copied from interface:ObjectLoaderLoad the links of the given "master" instance. Current "load filter" if set will be applied.- Specified by:
loadin interfaceObjectLoader<T extends StoredObject>- Parameters:
linkType- Link type.master- Master instance.condition- Filtering condition to be applied.orderedBy- "ORDER BY" clause to use while loading.any- Whether instanced of the subclasses to be retrieved or not.
-
load
Description copied from interface:ObjectLoaderLoad the instances created from the query. Current "load filter" if set will be applied. However,ObjectLoader.getOrderBy()result will be ignored.- Specified by:
loadin interfaceObjectLoader<T extends StoredObject>- Parameters:
query- Query from which objects to be loaded.any- Whether instanced of the subclasses to be retrieved or not.
-
load
Description copied from interface:ObjectLoaderLoad the instances created from the list ofIds. Current "load filter" if set will be applied. However,ObjectLoader.getOrderBy()result will be ignored. Also, the value returned byObjectLoader.getAllowAny()will determine whether instanced of the subclasses to be restricted or not.- Specified by:
loadin interfaceObjectLoader<T extends StoredObject>- Parameters:
idList- List ofIds from which objects to be loaded.
-
load
Description copied from interface:ObjectLoaderLoad the given instances. Current "load filter" if set will be applied. However,ObjectLoader.getOrderBy()result will be ignored. Also, the value returned byObjectLoader.getAllowAny()will determine whether instanced of the subclasses to be restricted or not.- Specified by:
loadin interfaceObjectLoader<T extends StoredObject>- Parameters:
objects- Objects to be loaded.
-
load
Description copied from interface:ObjectLoaderLoad the given instances. Current "load filter" if set will be applied. However,ObjectLoader.getOrderBy()result will be ignored. Also, the value returned byObjectLoader.getAllowAny()will determine whether instanced of the subclasses to be restricted or not.- Specified by:
loadin interfaceObjectLoader<T extends StoredObject>- Parameters:
objects- Objects to be loaded.
-
applyFilterPredicate
public void applyFilterPredicate()Description copied from interface:FilterMethodsThis method is called whenever a filter predicate is changed. Methods with default implementation already invoke this method. If any of those methods are overridden, make sure that it invokes this method so that logic to handle filter changes can be coded here.Note: This method is used to show the filtered result of the existing entries
- Specified by:
applyFilterPredicatein interfaceFilterMethods<T extends StoredObject>
-
getLoadFilter
Description copied from interface:FilterMethodsGet the load filter.- Specified by:
getLoadFilterin interfaceFilterMethods<T extends StoredObject>- Returns:
- Current load filter.
-
setAllowAny
public final void setAllowAny(boolean any) -
getObjectClass
Description copied from interface:ObjectLoaderThe class of the instances.- Specified by:
getObjectClassin interfaceObjectLoader<T extends StoredObject>- Returns:
- The class of the instances to load.
-
getCacheLevel
public int getCacheLevel() -
setCacheSize
public void setCacheSize(int size) -
getCacheSize
public int getCacheSize() -
close
public void close() -
refresh
public void refresh() -
refresh
-
refresh
-
size
public int size()Description copied from interface:ObjectLoaderGet the instances count.- Specified by:
sizein interfaceObjectLoader<T extends StoredObject>- Returns:
- Count.
-
size
public int size(int startingIndex, int endingIndex) -
getId
-
contains
-
contains
-
indexOf
-
indexOf
-
get
-
get
-
put
-
loopIds
-
loopIds
-
loopIds
-
listIds
-
listIds
-
listIds
-
getIdLoop
-
getIdBuffer
-
delete
-
delete
-
filter
-
sort
-
loop
-
loop
-
loop
-
list
-
list
-
list
-
stream
-
idStream
-
iterator
-