Class IngredientService
java.lang.Object
com.tccc.kos.commons.util.ready.ReadyBean
com.tccc.kos.commons.core.service.AbstractService
com.tccc.kos.ext.dispense.service.ingredient.IngredientService
- All Implemented Interfaces:
com.tccc.kos.commons.core.context.CtxEventListener
,com.tccc.kos.commons.core.service.handle.ContextHandleAware
,com.tccc.kos.commons.core.service.handle.HandleAware
,com.tccc.kos.commons.util.ready.Ready
,com.tccc.kos.commons.util.ready.ReadyListener
public final class IngredientService
extends com.tccc.kos.commons.core.service.AbstractService
Service that provides access to available ingredients. This provides a central service
that coordinates the installation and dissemination of ingredients along with relevant
lifecycle events.
Ingredients provided by this service are used during the insertion process to assign
ingredients to holders. This service just acts as a proxy to sources of ingredients
provided by IngredientSource
objects.
This service allows multiple ingredient sources to be registered and holders can be tagged with corresponding ingredient source id's to ensure that only ingredients from the tagged source can be inserted. The service has a concept of a default source which can be used in applications that don't require multiple distinct ingredients collections.
- Since:
- 1.0
- Version:
- 2023-01-25
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSource
(IngredientSource source) Add the ingredient source to the service.Return the default ingredient source.getIngredient
(String id) Return an ingredient for the specified ingredient id from the default source.getIngredient
(String sourceId, String id) Return an ingredient for the specified ingredient id in the specified source.Return theIngredientSource
with the specified id.Return the collection of ingredient sources.boolean
Return true if any source existsboolean
Return true if an ingredient source exists.void
removeSource
(String sourceId) Remove a source by the id of the source.void
setDefaultSource
(IngredientSource source) Add the source and use the source as the default ingredient source.Methods inherited from class com.tccc.kos.commons.core.service.AbstractService
getHandle, getHandlePrefix
Methods inherited from class com.tccc.kos.commons.util.ready.ReadyBean
getReady, onBeanReady, onDependenciesReady
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.tccc.kos.commons.core.context.CtxEventListener
onCtxAutowiringCompleted, onCtxDestroyed, onCtxPhaseCompleted
Methods inherited from interface com.tccc.kos.commons.core.service.handle.HandleAware
addHandleChild, getName, getPath
Methods inherited from interface com.tccc.kos.commons.util.ready.Ready
isReady, setReady
Methods inherited from interface com.tccc.kos.commons.util.ready.ReadyListener
onDependenciesGroupReady
-
Field Details
-
DEFAULT_INGREDIENT_SOURCE_SEPARATOR
- See Also:
-
-
Constructor Details
-
IngredientService
public IngredientService()
-
-
Method Details
-
setDefaultSource
Add the source and use the source as the default ingredient source.- Parameters:
source
- the new default ingredient source or null
-
getDefaultSource
Return the default ingredient source. -
addSource
Add the ingredient source to the service. This will replace any existing source with the same id.- Parameters:
source
- the ingredient source to add
-
removeSource
Remove a source by the id of the source.- Parameters:
sourceId
- the source of the id to remove
-
getSource
Return theIngredientSource
with the specified id.- Parameters:
sourceId
- id of the source to return
-
getSources
Return the collection of ingredient sources. -
hasSource
Return true if an ingredient source exists.- Parameters:
sourceId
- the id of the source to check
-
hasAnySource
public boolean hasAnySource()Return true if any source exists -
getIngredient
Return an ingredient for the specified ingredient id from the default source.- Parameters:
id
- the group id of the ingredient to return
-
getIngredient
Return an ingredient for the specified ingredient id in the specified source.- Parameters:
sourceId
- the id of the sourceid
- the id of the ingredient to return
-
getIngredientSourceSeparator
-