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 Details

  • Constructor Details

    • IngredientService

      public IngredientService()
  • Method Details

    • setDefaultSource

      public void setDefaultSource(IngredientSource source)
      Add the source and use the source as the default ingredient source.
      Parameters:
      source - the new default ingredient source or null
    • getDefaultSource

      public IngredientSource getDefaultSource()
      Return the default ingredient source.
    • addSource

      public void addSource(IngredientSource source)
      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

      public void removeSource(String sourceId)
      Remove a source by the id of the source.
      Parameters:
      sourceId - the source of the id to remove
    • getSource

      public IngredientSource getSource(String sourceId)
      Return the IngredientSource with the specified id.
      Parameters:
      sourceId - id of the source to return
    • getSources

      public Collection<IngredientSource> getSources()
      Return the collection of ingredient sources.
    • hasSource

      public boolean hasSource(String sourceId)
      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

      public BaseIngredient getIngredient(String id)
      Return an ingredient for the specified ingredient id from the default source.
      Parameters:
      id - the group id of the ingredient to return
    • getIngredient

      public BaseIngredient getIngredient(String sourceId, String id)
      Return an ingredient for the specified ingredient id in the specified source.
      Parameters:
      sourceId - the id of the source
      id - the id of the ingredient to return
    • getIngredientSourceSeparator

      public String getIngredientSourceSeparator()