Class IngredientService

java.lang.Object
com.kosdev.kos.ext.dispense.service.ingredient.IngredientService

public final class IngredientService extends Object
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
Version:
1
  • Field Details

  • 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
      Since:
      1
    • getDefaultSource

      public IngredientSource getDefaultSource()
      Return the default ingredient source.
      Since:
      1
    • 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
      Since:
      1
    • removeSource

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

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

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

      public boolean hasSource(String sourceId)
      Return true if an ingredient source exists.
      Parameters:
      sourceId - the id of the source to check
      Since:
      1
    • hasAnySource

      public boolean hasAnySource()
      Return true if any source exists
      Since:
      1
    • 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
      Since:
      1
    • 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
      Since:
      1
    • getIngredientSourceSeparator

      public String getIngredientSourceSeparator()