T
- public abstract class Stash<T extends Model> extends Object
Constructor and Description |
---|
Stash() |
Modifier and Type | Method and Description |
---|---|
abstract int |
countForKey(String keyName,
Object value)
Count the number of objects associated with an alternative key
|
abstract T |
detach(T obj)
Return a cloned version of the object.
|
abstract FilterChain<T> |
filterByKey(String key,
Object lookupValue)
Create a new filterChain, restricting it to items matching the lookupValue for the key
|
abstract FilterChain<T> |
filterChain()
Create a new FilterChain for this stash
|
abstract FilterChain<T> |
filterChain(List<T> subset)
Create a new filter chain using a subset of items
|
abstract T |
forId(Long id)
Get a cloned/detached object by id
|
abstract T |
forUniqueKey(String keyName,
Object value)
Retrieve an object via unique key.
|
String |
getBucket()
Get the bucket name
|
ModelController<T> |
getController()
Get the associated controller
|
abstract List<T> |
getItems()
All the items in the stash.
|
Set<String> |
getKeyFields()
Get the fields that have been defined as alternative lookup keys.
|
Persister<T> |
getPersister()
Get the associated persister
|
Set<String> |
getUniqueFields()
Get the field names that have been defined as unique keys.
|
abstract void |
hardDelete(T obj)
Remove the object from the stash and the underlying data store
|
void |
init(DataAccessRegistration registration,
ModelController<T> controller,
Persister<T> persister)
Initialized the Stash with required attributes, this is
called via dataAccess registration.
|
abstract List<T> |
listForKey(String keyName,
Object value)
Retrieve all objects for a given alternative key
|
abstract void |
loadAll()
Load all items from the datastore into the stash.
|
abstract void |
loadForId(Long id)
Load or reload the item with the given id from the datastore into the stash
|
abstract boolean |
loadItem(T obj)
Re-load the given object from the datastore into the stash
|
abstract void |
onPreRead()
Called before any of the data access methods run
|
abstract T |
originalForId(Long id)
Get the original object by id, if modified, the object in the stash
will be modified, so be careful.
|
T |
reloadIfNewer(T obj)
Reload from the underlying datastore if the stashed version is older
than the version in the datastore.
|
abstract void |
reset()
Reset the cache, nulling out all existing fields, and then reloading everything from
the database.
|
abstract void |
save(T obj)
Save the object to the stash and the underlying data store
|
Stash<T> |
setKeyFields(Set<String> keyFields) |
Stash<T> |
setUniqueFields(Set<String> uniqueFields) |
abstract void |
sync(T obj)
Take the passed in object, find the object in the stash with the same id, and
sync the data of the passed in object to the stashed object.
|
void |
syncForSave(T obj) |
public Stash()
public void init(DataAccessRegistration registration, ModelController<T> controller, Persister<T> persister)
registration
- controller
- persister
- public ModelController<T> getController()
public Persister<T> getPersister()
public Set<String> getKeyFields()
public Stash<T> setKeyFields(Set<String> keyFields)
public Set<String> getUniqueFields()
public Stash<T> setUniqueFields(Set<String> uniqueFields)
public abstract void sync(T obj)
obj
- public void syncForSave(T obj)
public abstract T detach(T obj)
obj
- public abstract void save(T obj)
obj
- public abstract void hardDelete(T obj)
obj
- public abstract void loadAll()
public abstract boolean loadItem(T obj)
obj
- public abstract void loadForId(Long id)
id
- public abstract void reset()
public abstract void onPreRead()
public T reloadIfNewer(T obj)
obj
- public abstract T originalForId(Long id)
id
- public abstract T forUniqueKey(String keyName, Object value)
keyName
- value
- public abstract List<T> listForKey(String keyName, Object value)
keyName
- value
- public abstract int countForKey(String keyName, Object value)
keyName
- value
- public abstract FilterChain<T> filterChain()
public abstract FilterChain<T> filterByKey(String key, Object lookupValue)
key
- - a model field that has been defined as a keylookupValue
- public abstract FilterChain<T> filterChain(List<T> subset)
subset
- Copyright © 2016. All rights reserved.