java.lang.Object
com.tccc.kos.ext.dispense.pipeline.beverage.graph.GraphNode
com.tccc.kos.ext.dispense.pipeline.beverage.graph.AndNode
All Implemented Interfaces:
Comparable<GraphNode>
Direct Known Subclasses:
BeverageNode

public class AndNode extends GraphNode
A GraphNode that reports availability as the logical AND of all of its child nodes. That is, this node is available/visible only if all all of its child nodes are available/visible.

This is useful for all-or-nothing relationships, such as a beverage only being available when all ingredients required by the beverage are available.

The default type of this node is "AND", but a custom type can be used to allow for improved searchability.

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

  • Constructor Details

    • AndNode

      public AndNode(String id)
      Creates an AND node with the specified ID and a type of "AND".
      Parameters:
      id - the ID of the node
    • AndNode

      public AndNode(String type, String id)
      Creates an AND node with the specified ID and type.

      Although the node has the specified type name, it still functions as an AND node. This is useful for creating a layer of AND nodes in a graph that can be easily searched by type.

      Parameters:
      type - the type of the node
      id - the ID of the node
  • Method Details

    • computeVisible

      public boolean computeVisible()
      Computes this node's visibility.

      An AND node is visible only when all of its child nodes are visible.

      Overrides:
      computeVisible in class GraphNode
    • computeAvailable

      public boolean computeAvailable()
      Computes this node's availability.

      An AND node is available only when all of its child nodes are available.

      Overrides:
      computeAvailable in class GraphNode