Class AiccPrerequisiteExpression

java.lang.Object
dev.jcputney.elearning.parser.input.aicc.prereq.AiccPrerequisiteExpression
All Implemented Interfaces:
Serializable

public final class AiccPrerequisiteExpression extends Object implements Serializable
Represents an AICC prerequisite expression used in specifying conditions for course prerequisites. This class encapsulates raw expressions, metadata about required and optional course components, and parsed details of the expression syntax and structure to facilitate evaluation and validation.
  • Raw Expression: The original prerequisite expression in string form.
  • Mandatory: Whether the prerequisite is a mandatory condition.
  • Referenced AU IDs: A list of course component identifiers referenced in the expression.
  • Optional AU IDs: A list of course components marked as optional within the expression.
  • Tokens: A set of tokens obtained from parsing the prerequisite expression in infix form.
  • Postfix Tokens: A set of tokens in postfix form for evaluation purposes.
  • Abstract Syntax Tree (AST): A representation of the expression's structure for conditional evaluation.
This class is immutable and hence thread-safe. All member lists are defensively copied during construction to ensure immutability.
See Also:
  • Constructor Details

    • AiccPrerequisiteExpression

      public AiccPrerequisiteExpression(String rawExpression, boolean mandatory, List<String> referencedAuIds, List<String> optionalAuIds, List<AiccPrerequisiteToken> tokens, List<AiccPrerequisiteToken> postfixTokens, AiccPrerequisiteNode ast)
      Constructs an instance of AiccPrerequisiteExpression with the specified parameters.
      Parameters:
      rawExpression - the raw prerequisite expression as a string
      mandatory - a boolean indicating whether the prerequisite expression is mandatory
      referencedAuIds - a list of strings representing the referenced AU (Assignable Unit) IDs in the prerequisite expression; can be null
      optionalAuIds - a list of strings representing the optional AU (Assignable Unit) IDs in the prerequisite expression; can be null
      tokens - a list of AiccPrerequisiteToken objects representing the tokens in the expression; can be null
      postfixTokens - a list of AiccPrerequisiteToken objects representing the tokens in postfix notation; can be null
      ast - the abstract syntax tree (AST) representing the prerequisite expression, as an AiccPrerequisiteNode instance; can be null
  • Method Details

    • minimal

      public static AiccPrerequisiteExpression minimal(String rawExpression, boolean mandatory)
      Creates a minimal instance of the AiccPrerequisiteExpression by initializing only the essential fields.
      Parameters:
      rawExpression - the raw prerequisite expression as a string
      mandatory - a boolean indicating whether the prerequisite expression is mandatory
      Returns:
      an instance of AiccPrerequisiteExpression with minimal configuration
    • getRawExpression

      public String getRawExpression()
      Retrieves the raw prerequisite expression as provided during the creation of this instance.
      Returns:
      the raw prerequisite expression as a string
    • isMandatory

      public boolean isMandatory()
      Determines whether the prerequisite expression is mandatory.
      Returns:
      true if the prerequisite is mandatory, false otherwise
    • getReferencedAuIds

      public List<String> getReferencedAuIds()
      Retrieves the list of referenced AU (Assignable Unit) IDs that are part of the prerequisite expression.
      Returns:
      a list of strings, each representing a referenced AU ID.
    • getOptionalAuIds

      public List<String> getOptionalAuIds()
      Retrieves the list of optional AU (Assignable Unit) IDs that are part of the prerequisite expression.
      Returns:
      a list of strings, each representing an optional AU ID.
    • getTokens

      public List<AiccPrerequisiteToken> getTokens()
      Retrieves the list of tokens that are part of the AICC prerequisite expression.
      Returns:
      a list of AiccPrerequisiteToken objects representing the tokens in the expression.
    • getPostfixTokens

      public List<AiccPrerequisiteToken> getPostfixTokens()
      Retrieves the list of tokens that represent the postfix notation of the AICC prerequisite expression. Postfix notation is a mathematical notation in which operators follow their operands. This list represents the parsed expression in a format suitable for evaluation or further processing.
      Returns:
      a list of AiccPrerequisiteToken objects, each representing a token in the postfix notation of the prerequisite expression.
    • getAst

      public AiccPrerequisiteNode getAst()
      Retrieves the abstract syntax tree (AST) representation of the AICC prerequisite expression. The AST is a hierarchical structure of AiccPrerequisiteNode objects that defines the logical composition of the prerequisite expression, including its operators and components.
      Returns:
      the root node of the abstract syntax tree, represented as an instance of AiccPrerequisiteNode.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object