Class AiRequiresEntry

java.lang.Object
tools.pantheum.gaia.gs1.registry.AiRequiresEntry

public class AiRequiresEntry extends Object
Represents one OR option in an AI's requires list.

Three forms:

  • Single — one exact AI code must be present.
  • Group — all AI codes in the list must be present (AND).
  • Range — at least one AI whose code falls within [rangeStart, rangeEnd] must be present.

The outer list of AiRequiresEntry on an AiDefinition is OR: at least one entry must be satisfied for the requires constraint to pass.

  • Method Details

    • ofSingle

      public static AiRequiresEntry ofSingle(String ai)
      Of single.
      Parameters:
      ai - the AI
      Returns:
      a new AiRequiresEntry
    • ofGroup

      public static AiRequiresEntry ofGroup(List<String> ais)
      Of group.
      Parameters:
      ais - the AIs
      Returns:
      a new AiRequiresEntry
    • ofRange

      public static AiRequiresEntry ofRange(String start, String end)
      Of range.
      Parameters:
      start - the start
      end - the end
      Returns:
      a new AiRequiresEntry
    • isRange

      public boolean isRange()
      Returns true if this element is range.
      Returns:
      true if this element is range.
    • isGroup

      public boolean isGroup()
      Returns true if this element is group.
      Returns:
      true if this element is group.
    • isSingle

      public boolean isSingle()
      Returns true if this element is single.
      Returns:
      true if this element is single.
    • getExactAi

      public String getExactAi()
      Returns the exact AI.
      Returns:
      the exact AI.
    • getGroup

      public List<String> getGroup()
      Returns the group.
      Returns:
      the group.
    • getRangeStart

      public String getRangeStart()
      Returns the range start.
      Returns:
      the range start.
    • getRangeEnd

      public String getRangeEnd()
      Returns the range end.
      Returns:
      the range end.
    • isSatisfiedBy

      public boolean isSatisfiedBy(Set<String> presentAis)
      Returns true if this requires option is satisfied by the given set of present AI codes.
      • Single — the exact AI is present.
      • Group — all AIs in the group are present.
      • Range — at least one present AI falls within the range.
      Parameters:
      presentAis - the present AIs
      Returns:
      true if is satisfied by.
    • toString

      public String toString()
      Overrides:
      toString in class Object