All Implemented Interfaces:
Comparable<GraphNode>

public class IngredientNode extends OrNode
A GraphNode that represents an ingredient.

This is simply an OR node with a type of "INGREDIENT". It stores an ingredient ID independent of the node ID, in the event that the node ID cannot be the ingredient ID due to ID collisions.

Child nodes of an ingredient node are typically pump nodes. This allows for multiple sources of an ingredient to be represented as a single ingredient to the next layer in the graph, which is typically beverages. This allows a beverage to depend on an ingredient such as orange, but not care if there are two pumps that have orange assigned. So long as either of the pumps are available, the ingredient is available.

BevGraphBuilder provides addIngredientNodes() which builds the ingredient layer of nodes automatically.

Since:
1.0
Version:
2023-02-10
  • Field Details

  • Constructor Details

    • IngredientNode

      public IngredientNode(BaseIngredient ingredient)
      Creates an ingredient node where the given ingredientId is both the id and altId of the node.
      Parameters:
      ingredient - both ID and altId of the node are ingredientId
    • IngredientNode

      public IngredientNode(String id, BaseIngredient ingredient)
      Creates an ingredient node where the id of the node is distinct from the associated ingredientId . The ingredientId is stored in the node's altId field.
      Parameters:
      id - ID of the node
      ingredient - the ingredient for the node
  • Method Details

    • getIngredientId

      public String getIngredientId()
      Returns the ingredient ID of the node, which is this node's altId .
    • toString

      public String toString()
      Overrides:
      toString in class GraphNode
    • getIngredient

      public BaseIngredient getIngredient()