Record Class ContractConfig

java.lang.Object
java.lang.Record
com.tnsai.metadata.ContractConfig
Record Components:
precondition - precondition expression
postcondition - postcondition expression
fulfills - goal names this action fulfills
effects - state effects of this action
autoApplyEffects - whether effects are auto-applied after execution

public record ContractConfig(String precondition, String postcondition, String[] fulfills, Effect[] effects, boolean autoApplyEffects) extends Record
Grouped configuration for action contracts and planning effects.

Extracts and organizes the contract/planning fields from

invalid reference
ActionSpec
, providing a cohesive view of preconditions, postconditions, goal fulfillment, and state effects.

This record is part of the ActionConfig decomposition (C-20), splitting ActionSpec's 60+ fields into focused, type-specific records.

Usage


 ActionSpec action = ...;
 ContractConfig contract = action.contractConfig();
 if (contract.hasPrecondition()) {
     evaluate(contract.precondition());
 }
 
See Also:
  • invalid reference
    ActionSpec#contractConfig()
  • Field Details

    • DEFAULT

      public static final ContractConfig DEFAULT
      Default configuration with no contracts.
  • Constructor Details

    • ContractConfig

      public ContractConfig(String precondition, String postcondition, String[] fulfills, Effect[] effects, boolean autoApplyEffects)
      Creates an instance of a ContractConfig record class.
      Parameters:
      precondition - the value for the precondition record component
      postcondition - the value for the postcondition record component
      fulfills - the value for the fulfills record component
      effects - the value for the effects record component
      autoApplyEffects - the value for the autoApplyEffects record component
  • Method Details

    • hasPrecondition

      public boolean hasPrecondition()
      Checks if a precondition is defined.
      Returns:
      true if precondition is not empty
    • hasPostcondition

      public boolean hasPostcondition()
      Checks if a postcondition is defined.
      Returns:
      true if postcondition is not empty
    • hasFulfills

      public boolean hasFulfills()
      Checks if this action fulfills any goals.
      Returns:
      true if fulfills array is not empty
    • hasEffects

      public boolean hasEffects()
      Checks if effects are defined.
      Returns:
      true if effects array is not empty
    • hasAnyContract

      public boolean hasAnyContract()
      Checks if any contract element is defined.
      Returns:
      true if any precondition, postcondition, or effect exists
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • precondition

      public String precondition()
      Returns the value of the precondition record component.
      Returns:
      the value of the precondition record component
    • postcondition

      public String postcondition()
      Returns the value of the postcondition record component.
      Returns:
      the value of the postcondition record component
    • fulfills

      public String[] fulfills()
      Returns the value of the fulfills record component.
      Returns:
      the value of the fulfills record component
    • effects

      public Effect[] effects()
      Returns the value of the effects record component.
      Returns:
      the value of the effects record component
    • autoApplyEffects

      public boolean autoApplyEffects()
      Returns the value of the autoApplyEffects record component.
      Returns:
      the value of the autoApplyEffects record component