public class KeyValueCollectionLoaderImpl extends java.lang.Object implements KeyValueCollectionLoader
KeyValueCollectionLoader.PostLoadEvent, KeyValueCollectionLoader.PreLoadEvent
Modifier and Type | Field and Description |
---|---|
protected org.springframework.context.ApplicationContext |
applicationContext |
protected Condition |
condition |
protected KeyValueCollectionContainer |
container |
protected DataContext |
dataContext |
protected java.util.function.Function<ValueLoadContext,java.util.List<KeyValueEntity>> |
delegate |
protected EventHub |
events |
protected int |
firstResult |
protected int |
maxResults |
protected java.util.Map<java.lang.String,java.lang.Object> |
parameters |
protected java.lang.String |
query |
protected boolean |
softDeletion |
protected Sort |
sort |
protected java.lang.String |
storeName |
Constructor and Description |
---|
KeyValueCollectionLoaderImpl(org.springframework.context.ApplicationContext applicationContext) |
Modifier and Type | Method and Description |
---|---|
Subscription |
addPostLoadListener(java.util.function.Consumer<KeyValueCollectionLoader.PostLoadEvent> listener)
Adds a listener to
KeyValueCollectionLoader.PostLoadEvent . |
Subscription |
addPreLoadListener(java.util.function.Consumer<KeyValueCollectionLoader.PreLoadEvent> listener)
Adds a listener to
KeyValueCollectionLoader.PreLoadEvent . |
ValueLoadContext |
createLoadContext()
Returns
ValueLoadContext which is created by the parameters of this loader. |
Condition |
getCondition()
Returns the root condition which is used together with the query when loading entities.
|
KeyValueCollectionContainer |
getContainer()
Returns the container which accepts loaded entities.
|
DataContext |
getDataContext()
Returns data context.
|
protected DataManager |
getDataManager() |
java.util.function.Function<ValueLoadContext,java.util.List<KeyValueEntity>> |
getDelegate()
Returns a function which will be used to load data instead of standard implementation.
|
int |
getFirstResult()
The position of the first instance to load, numbered from 0.
|
int |
getMaxResults()
The maximum number of instances to load.
|
java.lang.Object |
getParameter(java.lang.String name)
Returns a query parameter by its name.
|
java.util.Map<java.lang.String,java.lang.Object> |
getParameters()
Returns the map of query parameters.
|
java.lang.String |
getQuery()
Returns the query which is used for loading entities.
|
Sort |
getSort()
Returns the sort object which is used when loading.
|
protected SorterFactory |
getSorterFactory() |
java.lang.String |
getStoreName()
Returns data store name.
|
boolean |
isSoftDeletion()
Returns true if the loader respects soft deletion, i.e.
|
void |
load()
Loads data to the connected container.
|
void |
removeParameter(java.lang.String name)
Removes a query parameter.
|
protected void |
sendPostLoadEvent(java.util.List<KeyValueEntity> entities) |
protected boolean |
sendPreLoadEvent(ValueLoadContext loadContext) |
void |
setCondition(Condition condition)
Sets the root condition which will be used together with the query when loading entities.
|
void |
setContainer(KeyValueCollectionContainer container)
Sets the container which accepts loaded entities.
|
void |
setDataContext(DataContext dataContext)
Sets the data context for the loader.
|
void |
setFirstResult(int firstResult)
Sets the position of the first instance to load, numbered from 0.
|
void |
setLoadDelegate(java.util.function.Function<ValueLoadContext,java.util.List<KeyValueEntity>> delegate)
Sets a function which will be used to load data instead of standard implementation.
|
void |
setMaxResults(int maxResults)
Sets the maximum number of instances to load.
|
void |
setParameter(java.lang.String name,
java.lang.Object value)
Sets a query parameter.
|
void |
setParameters(java.util.Map<java.lang.String,java.lang.Object> parameters)
Sets the map of query parameters.
|
void |
setQuery(java.lang.String query)
Sets a query which will be used for loading entities.
|
void |
setSoftDeletion(boolean softDeletion)
Set to false if you want to load softly deleted instances too.
|
void |
setSort(Sort sort)
Sets the sort object which is used when loading.
|
void |
setStoreName(java.lang.String name)
Sets the data store name.
|
protected org.springframework.context.ApplicationContext applicationContext
protected DataContext dataContext
protected KeyValueCollectionContainer container
protected java.lang.String query
protected Condition condition
protected java.util.Map<java.lang.String,java.lang.Object> parameters
protected int firstResult
protected int maxResults
protected boolean softDeletion
protected Sort sort
protected java.lang.String storeName
protected java.util.function.Function<ValueLoadContext,java.util.List<KeyValueEntity>> delegate
protected EventHub events
public KeyValueCollectionLoaderImpl(org.springframework.context.ApplicationContext applicationContext)
protected DataManager getDataManager()
protected SorterFactory getSorterFactory()
@Nullable public DataContext getDataContext()
DataLoader
getDataContext
in interface DataLoader
public void setDataContext(DataContext dataContext)
DataLoader
setDataContext
in interface DataLoader
public void load()
DataLoader
load
in interface DataLoader
public ValueLoadContext createLoadContext()
KeyValueCollectionLoader
ValueLoadContext
which is created by the parameters of this loader. The ValueLoadContext
can be used with DataManager
to load data by the same conditions.createLoadContext
in interface KeyValueCollectionLoader
protected boolean sendPreLoadEvent(ValueLoadContext loadContext)
protected void sendPostLoadEvent(java.util.List<KeyValueEntity> entities)
public KeyValueCollectionContainer getContainer()
KeyValueCollectionLoader
getContainer
in interface BaseCollectionLoader
getContainer
in interface DataLoader
getContainer
in interface KeyValueCollectionLoader
public void setContainer(KeyValueCollectionContainer container)
KeyValueCollectionLoader
setContainer
in interface KeyValueCollectionLoader
public java.lang.String getQuery()
DataLoader
getQuery
in interface DataLoader
public void setQuery(java.lang.String query)
DataLoader
setQuery
in interface DataLoader
public Condition getCondition()
DataLoader
getCondition
in interface DataLoader
public void setCondition(Condition condition)
DataLoader
setCondition
in interface DataLoader
public java.util.Map<java.lang.String,java.lang.Object> getParameters()
DataLoader
getParameters
in interface DataLoader
public void setParameters(java.util.Map<java.lang.String,java.lang.Object> parameters)
DataLoader
setParameters
in interface DataLoader
public java.lang.Object getParameter(java.lang.String name)
DataLoader
getParameter
in interface DataLoader
public void setParameter(java.lang.String name, java.lang.Object value)
DataLoader
setParameter
in interface DataLoader
public void removeParameter(java.lang.String name)
DataLoader
removeParameter
in interface DataLoader
public int getMaxResults()
BaseCollectionLoader
Integer.MAX_VALUE
if BaseCollectionLoader.setMaxResults(int)
was not called.getMaxResults
in interface BaseCollectionLoader
public void setMaxResults(int maxResults)
BaseCollectionLoader
setMaxResults
in interface BaseCollectionLoader
public Sort getSort()
BaseCollectionLoader
getSort
in interface BaseCollectionLoader
public void setSort(Sort sort)
BaseCollectionLoader
setSort
in interface BaseCollectionLoader
public java.util.function.Function<ValueLoadContext,java.util.List<KeyValueEntity>> getDelegate()
KeyValueCollectionLoader
getDelegate
in interface KeyValueCollectionLoader
public void setLoadDelegate(java.util.function.Function<ValueLoadContext,java.util.List<KeyValueEntity>> delegate)
KeyValueCollectionLoader
setLoadDelegate
in interface KeyValueCollectionLoader
public Subscription addPreLoadListener(java.util.function.Consumer<KeyValueCollectionLoader.PreLoadEvent> listener)
KeyValueCollectionLoader
KeyValueCollectionLoader.PreLoadEvent
.
You can also add an event listener declaratively using a controller method annotated with Subscribe
:
@Subscribe(id = "fooDl", target = Target.DATA_LOADER) private void onFooDlPreLoad(KeyValueCollectionLoader.PreLoadEvent event) { // handle event here }
addPreLoadListener
in interface KeyValueCollectionLoader
listener
- listenerpublic Subscription addPostLoadListener(java.util.function.Consumer<KeyValueCollectionLoader.PostLoadEvent> listener)
KeyValueCollectionLoader
KeyValueCollectionLoader.PostLoadEvent
.
You can also add an event listener declaratively using a controller method annotated with Subscribe
:
@Subscribe(id = "fooDl", target = Target.DATA_LOADER) private void onFooDlPostLoad(KeyValueCollectionLoader.PostLoadEvent event) { // handle event here }
addPostLoadListener
in interface KeyValueCollectionLoader
listener
- listenerpublic boolean isSoftDeletion()
DataLoader
isSoftDeletion
in interface DataLoader
public void setSoftDeletion(boolean softDeletion)
DataLoader
setSoftDeletion
in interface DataLoader
public java.lang.String getStoreName()
KeyValueCollectionLoader
getStoreName
in interface KeyValueCollectionLoader
public void setStoreName(java.lang.String name)
KeyValueCollectionLoader
setStoreName
in interface KeyValueCollectionLoader
public int getFirstResult()
BaseCollectionLoader
BaseCollectionLoader.setFirstResult(int)
was not called.getFirstResult
in interface BaseCollectionLoader
public void setFirstResult(int firstResult)
BaseCollectionLoader
setFirstResult
in interface BaseCollectionLoader