-
- All Implemented Interfaces:
-
com.onesignal.common.events.IEventNotifier
public interface IModelStore<TModel extends Model> implements IEventNotifier<IModelStoreChangeHandler<TModel>>
A model store provides access to the underlying models. A model store is a key store, each model in the model store must have a unique Model.id for retrieving a specific model.
-
-
Method Summary
Modifier and Type Method Description abstract TModelcreate(JSONObject jsonObject)Create a new instance of the model and add it to the store. abstract Collection<TModel>list()List the models that are owned by this model store. abstract Unitadd(TModel model, String tag)Add a new model to this model store. abstract Unitadd(Integer index, TModel model, String tag)Add a new model to this model store. abstract TModelget(String id)Retrieve the model associated to the id provided. abstract Unitremove(String id, String tag)Remove the model associated to the id provided from the model store. abstract Unitclear(String tag)Remove all models from the store. abstract UnitreplaceAll(List<TModel> models, String tag)Replace all models in the store with the provided models. abstract BooleangetHasSubscribers()Whether there are currently any subscribers. -
-
Method Detail
-
create
abstract TModel create(JSONObject jsonObject)
Create a new instance of the model and add it to the store. The new instance is not added to the model store, because it may not yet have an Model.id which is required.
- Parameters:
jsonObject- The optional JSONObject to initialize the new model with.
-
list
abstract Collection<TModel> list()
List the models that are owned by this model store.
-
add
abstract Unit add(TModel model, String tag)
Add a new model to this model store. Once added, any changes to the model will trigger calls to an IModelStoreChangeHandler that has subscribed to this model store. This same instance is also retrievable via get based on Model.id.
- Parameters:
model- The model being added to the model store.tag- The tag which identifies how/why the model is being added.
-
add
abstract Unit add(Integer index, TModel model, String tag)
Add a new model to this model store. Once added, any changes to the model will trigger calls to an IModelStoreChangeHandler that has subscribed to this model store. This same instance is also retrievable via get based on Model.id.
- Parameters:
index- The index to add it undermodel- The model being added to the model store.tag- The tag which identifies how/why the model is being added.
-
get
abstract TModel get(String id)
Retrieve the model associated to the id provided.
- Parameters:
id- The unique identifier for the model to retrieve.
-
remove
abstract Unit remove(String id, String tag)
Remove the model associated to the id provided from the model store.
- Parameters:
id- The unique identifier to the model to remove.tag- The tag which identifies how/why the model is being removed.
-
clear
abstract Unit clear(String tag)
Remove all models from the store.
- Parameters:
tag- The tag which identifies how/why the model store is being cleared.
-
replaceAll
abstract Unit replaceAll(List<TModel> models, String tag)
Replace all models in the store with the provided models.
- Parameters:
models- The models to track in the model store.tag- The tag which identifies how/why the model store is being replaced.
-
getHasSubscribers
abstract Boolean getHasSubscribers()
Whether there are currently any subscribers.
-
-
-
-