public abstract class AbstractPersister<T,ID> extends Object implements Persister<T>
Constructor and Description |
---|
AbstractPersister(List<State<T>> states,
String stateFieldName,
State<T> startState,
Class<T> clazz) |
Modifier and Type | Method and Description |
---|---|
protected FieldAccessor<T,ID> |
buildIdFieldAccessor(Field idField,
Class<T> clazz) |
protected StateFieldAccessor<T> |
buildStateFieldAccessor(Field stateField,
Class<T> clazz) |
protected abstract Field |
findIdField(Class<?> clazz) |
protected Field |
findStateField(String stateFieldName,
Class<?> clazz) |
protected Class<T> |
getClazz() |
State<T> |
getCurrent(T stateful)
Returns the current state.
|
protected Object |
getId(T obj) |
Field |
getIdField() |
protected FieldAccessor<T,ID> |
getIdFieldAccessor() |
protected State<T> |
getStartState() |
protected Serializable |
getState(T obj) |
Field |
getStateField() |
protected StateFieldAccessor<T> |
getStateFieldAccessor() |
protected abstract Class<?> |
getStateFieldType() |
abstract void |
setCurrent(T stateful,
State<T> current,
State<T> next)
Set the current State.
|
void |
setStartState(State<T> startState)
Set the Start State
|
protected void |
setState(T obj,
String state) |
void |
setStates(Collection<State<T>> states)
Set the Collection of States to be managed by the Persister
|
protected void |
throwStaleState(State<T> current,
State<T> next) |
protected abstract boolean |
validStateField(Field stateField) |
public State<T> getCurrent(T stateful)
Persister
getCurrent
in interface Persister<T>
stateful
- Stateful Entitypublic abstract void setCurrent(T stateful, State<T> current, State<T> next) throws StaleStateException
setCurrent
in interface Persister<T>
stateful
- Stateful Entitycurrent
- Expected current Statenext
- The value of the next StateStaleStateException
- thrown if the value of the State does not equal to the provided current Statepublic void setStates(Collection<State<T>> states)
Persister
public void setStartState(State<T> startState)
Persister
setStartState
in interface Persister<T>
startState
- Start Statepublic Field getIdField()
public Field getStateField()
protected abstract boolean validStateField(Field stateField)
protected FieldAccessor<T,ID> buildIdFieldAccessor(Field idField, Class<T> clazz)
protected StateFieldAccessor<T> buildStateFieldAccessor(Field stateField, Class<T> clazz)
protected abstract Class<?> getStateFieldType()
protected Object getId(T obj) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
protected Serializable getState(T obj) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
protected void setState(T obj, String state) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException
protected void throwStaleState(State<T> current, State<T> next) throws StaleStateException
StaleStateException
protected StateFieldAccessor<T> getStateFieldAccessor()
protected FieldAccessor<T,ID> getIdFieldAccessor()
Copyright © 2016. All rights reserved.