public interface AlexaStateHandler
Modifier and Type | Method and Description |
---|---|
<TModel extends AlexaStateModel> |
createModel(Class<TModel> modelClass)
Creates an instance of your model class and binds it to this handler.
|
<TModel extends AlexaStateModel> |
createModel(Class<TModel> modelClass,
String id)
Creates an instance of your model class and binds it to this handler.
|
<TModel extends AlexaStateModel> |
exists(Class<TModel> modelClass)
Looks for a model in the persistence store.
|
<TModel extends AlexaStateModel> |
exists(Class<TModel> modelClass,
AlexaScope scope)
Looks for a model in the persistence store in a given scope.
|
<TModel extends AlexaStateModel> |
exists(Class<TModel> modelClass,
String id)
Looks for a model with given id in the persistence store.
|
<TModel extends AlexaStateModel> |
exists(Class<TModel> modelClass,
String id,
AlexaScope scope)
Looks for a model with the given id in the persistence store in a given scope.
|
boolean |
exists(String id)
Looks for a state object with the given id.
|
boolean |
exists(String id,
AlexaScope scope)
Looks for a state object with the given id in the given scope.
|
com.amazon.speech.speechlet.Session |
getSession()
Returns the Alexa Session object which was given to this handler.
|
<TModel extends AlexaStateModel> |
readModel(Class<TModel> modelClass)
Reads out the model from the persistence store of this handler.
|
<TModel extends AlexaStateModel> |
readModel(Class<TModel> modelClass,
String id)
Reads out the model from the persistence store of this handler.
|
<TModel extends AlexaStateModel> |
readModels(Class<TModel> modelClass,
Collection<String> ids)
Reads out models from the persistence store of this handler.
|
Optional<AlexaStateObject> |
readValue(String id)
Reads a single object value from the persistence store.
|
Optional<AlexaStateObject> |
readValue(String id,
AlexaScope scope)
Reads a single object value from the persistence store.
|
Map<String,AlexaStateObject> |
readValues(Collection<String> ids)
Reads multiple single object values from the persistence store.
|
Map<String,AlexaStateObject> |
readValues(Collection<String> ids,
AlexaScope scope)
Reads multiple single object values from the persistence store in a specific scope.
|
Map<String,AlexaStateObject> |
readValues(Map<String,AlexaScope> idsInScope)
Reads multiple single object values from the persistence store in scopes.
|
void |
removeModel(AlexaStateModel model)
The given model will be removed from the persistence store.
|
void |
removeModels(Collection<? extends AlexaStateModel> models)
The given models will be removed from the persistence store.
|
void |
removeValue(String id)
Removes a single value state from the persistence store with the given key used
when single value was written in store.
|
void |
removeValues(Collection<String> ids)
Removes multiple value states from the persistence store with given keys used
when those values were written in store.
|
void |
writeModel(AlexaStateModel model)
The given model will be saved in the persistence store according to its
AlexaStateSave -annotations. |
void |
writeModels(Collection<? extends AlexaStateModel> models)
The given models will be saved in the persistence store according to their
AlexaStateSave -annotations. |
void |
writeValue(AlexaStateObject stateObject)
The value of a given state object will be saved with its id in the persistence store.
|
void |
writeValue(String id,
Object value)
The given value will be saved with the given id in the persistence store.
|
void |
writeValue(String id,
Object value,
AlexaScope scope)
The given value will be saved with the given id in the persistence store.
|
void |
writeValues(Collection<? extends AlexaStateObject> stateObjects)
Values of given state objects will be saved with their ids in the persistence store.
|
com.amazon.speech.speechlet.Session getSession()
<TModel extends AlexaStateModel> TModel createModel(Class<TModel> modelClass)
AlexaStateModel.saveState()
or AlexaStateModel.removeState()
)
This really much does the same as what you can achieve with AlexaStateModelFactory.createModel(Class, AlexaStateHandler)
.
Of course you can initialize your models with its own constructor but make sure you setHandler() before
calling aforementioned methods of this model.
By using this method you are not assigning an id to the model. Your model behaves like a singleton within
its AlexaScope (Session, User or Application) and is overridden on AlexaStateModel.saveState()
if already existent.TModel
- type derived from AlexaStateModel
modelClass
- type of your model you want to initialize. Model has to derive from AlexaStateModel
<TModel extends AlexaStateModel> TModel createModel(Class<TModel> modelClass, String id)
AlexaStateModel.saveState()
or AlexaStateModel.removeState()
)
This really much does the same as what you can achieve with AlexaStateModelFactory.createModel(Class, AlexaStateHandler)
.
Of course you can initialize your models with its own constructor but make sure you AlexaStateModel.setHandler(AlexaStateHandler)
before
calling aforementioned methods of this model.
By using this method you will assign an id to the model. From now on this id is used to read and
write to the persistence store associated with the handler. It gives you freedom to have more than one of a kind
of your model within its AlexaScope
(Session, User, Application)TModel
- type derived from AlexaStateModel
modelClass
- type of your model you want to initialize. Model has to derive from AlexaStateModel
id
- An id unique within a model's AlexaScope
. If a model with this id is already existing in the persistence store it will be overridden on AlexaStateModel.saveState()
.void writeModel(AlexaStateModel model) throws AlexaStateException
AlexaStateSave
-annotations.
If you set up an Id for the model it will be accessible with it on later reads to the handler.model
- Your model which needs to be a type of AlexaStateModel
AlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelvoid writeModels(Collection<? extends AlexaStateModel> models) throws AlexaStateException
AlexaStateSave
-annotations.
If you set up an Id for the model it will be accessible with it on later reads to the handler.
If you have multiple models to save always prefer this method as it tries to batch process
the models so it reduces the number of write-transactions to one.models
- list of models to save stateAlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelvoid writeValue(String id, Object value) throws AlexaStateException
id
- the key used when writing value to the storevalue
- the actual object whose value will be savedAlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelvoid writeValue(String id, Object value, AlexaScope scope) throws AlexaStateException
id
- the key used when writing value to the storevalue
- the actual object whose value will be savedscope
- the scope the value is savedAlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelvoid writeValue(AlexaStateObject stateObject) throws AlexaStateException
stateObject
- the state object to write to the persistence storeAlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelvoid writeValues(Collection<? extends AlexaStateObject> stateObjects) throws AlexaStateException
stateObjects
- the state objects to write to the persistence storeAlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelvoid removeModel(AlexaStateModel model) throws AlexaStateException
model
- Your model which needs to be a type of AlexaStateModel
AlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelvoid removeModels(Collection<? extends AlexaStateModel> models) throws AlexaStateException
models
- Your models which need to be a type of AlexaStateModel
AlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelvoid removeValue(String id) throws AlexaStateException
id
- the key of a single value object whose state you want to remove from the store.AlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelvoid removeValues(Collection<String> ids) throws AlexaStateException
ids
- the keys of single value objects whose state you want to remove from the store.AlexaStateException
- Wraps all inner exceptions and gives you context related to handler and model<TModel extends AlexaStateModel> Optional<TModel> readModel(Class<TModel> modelClass) throws AlexaStateException
AlexaScope
s configured in
the AlexaStateSave
annotations it will possibly collect data from more than one persistence store. (most
likely from the Alexa session and maybe from the permanent persistence store associated with this handler.
You are not providing an id with this call. Thus it will look for the single representative without an id.TModel
- Type derived from AlexaStateModel
modelClass
- Type of the model you would like to read out. It needs to be of type AlexaStateModel
.AlexaStateException
- Wraps all inner exceptions and gives you context related to handler and model<TModel extends AlexaStateModel> Optional<TModel> readModel(Class<TModel> modelClass, String id) throws AlexaStateException
AlexaScope
s configured in
the AlexaStateSave
annotations it will possibly collect data from more than one persistence store. (most
likely from the Alexa session and maybe from the permanent persistence store associated with this handler.
You are providing an id with this call. If you never saved the model with this id in the store you won't get anything.TModel
- Type derived from AlexaStateModel
modelClass
- Type of the model you would like to read out. It needs to be of type AlexaStateModel
.id
- The id of an existing instance of your model in the persistence store.AlexaStateException
- Wraps all inner exceptions and gives you context related to handler and model<TModel extends AlexaStateModel> Map<String,TModel> readModels(Class<TModel> modelClass, Collection<String> ids) throws AlexaStateException
AlexaScope
s configured in
the AlexaStateSave
annotations it will possibly collect data from more than one persistence store. (most
likely from the Alexa session and maybe from the permanent persistence store associated with this handler.)
You are providing ids with this call. If you never saved any model with one of the ids in the store you won't get them.TModel
- Type derived from AlexaStateModel
modelClass
- Type of the model you would like to read out. It needs to be of type AlexaStateModel
.ids
- Collection of ids of existing instances of your model in the persistence store. If you provide ids of non-existing items they just won't show up in the returned map.AlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelOptional<AlexaStateObject> readValue(String id) throws AlexaStateException
id
- id of a state-object whose state you want to read from the store.AlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelOptional<AlexaStateObject> readValue(String id, AlexaScope scope) throws AlexaStateException
id
- id of a state-object whose state you want to read from the store.scope
- read state-object in that scope.AlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelMap<String,AlexaStateObject> readValues(Collection<String> ids) throws AlexaStateException
ids
- ids of state-objects whose state you want to read from the store.AlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelMap<String,AlexaStateObject> readValues(Collection<String> ids, AlexaScope scope) throws AlexaStateException
ids
- ids of state-objects whose state you want to read from the store.scope
- read state-objects in that scope.AlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelMap<String,AlexaStateObject> readValues(Map<String,AlexaScope> idsInScope) throws AlexaStateException
idsInScope
- ids with scope of state-objects whose state you want to read from the store.AlexaStateException
- Wraps all inner exceptions and gives you context related to handler and model<TModel extends AlexaStateModel> boolean exists(Class<TModel> modelClass) throws AlexaStateException
TModel
- Type derived from AlexaStateModel
modelClass
- Type of the model you would like to check for existence. It needs to be of type AlexaStateModel
.AlexaStateException
- Wraps all inner exceptions and gives you context related to handler and model<TModel extends AlexaStateModel> boolean exists(Class<TModel> modelClass, String id) throws AlexaStateException
TModel
- Type derived from AlexaStateModel
modelClass
- Type of the model you would like to check for existence. It needs to be of type AlexaStateModel
.id
- the id of a modelAlexaStateException
- Wraps all inner exceptions and gives you context related to handler and model<TModel extends AlexaStateModel> boolean exists(Class<TModel> modelClass, AlexaScope scope) throws AlexaStateException
TModel
- Type derived from AlexaStateModel
modelClass
- Type of the model you would like to check for existence. It needs to be of type AlexaStateModel
.scope
- scope in which to test existence of modelAlexaStateException
- Wraps all inner exceptions and gives you context related to handler and model<TModel extends AlexaStateModel> boolean exists(Class<TModel> modelClass, String id, AlexaScope scope) throws AlexaStateException
TModel
- Type derived from AlexaStateModel
modelClass
- Type of the model you would like to check for existence. It needs to be of type AlexaStateModel
.id
- the id of a modelscope
- scope in which to test existence of modelAlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelboolean exists(String id) throws AlexaStateException
id
- id of a state-object whose existence you want to be checked in the store.AlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelboolean exists(String id, AlexaScope scope) throws AlexaStateException
id
- id of a state-object whose existence you want to be checked in the store.scope
- look for state-object in that scope.AlexaStateException
- Wraps all inner exceptions and gives you context related to handler and modelCopyright © 2017. All rights reserved.