Package com.tnsai.metadata
Record Class ContractConfig
java.lang.Object
java.lang.Record
com.tnsai.metadata.ContractConfig
- Record Components:
precondition- precondition expressionpostcondition- postcondition expressionfulfills- goal names this action fulfillseffects- state effects of this actionautoApplyEffects- 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
, providing a cohesive view of preconditions, postconditions,
goal fulfillment, and state effects.
invalid reference
ActionSpec
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ContractConfigDefault configuration with no contracts. -
Constructor Summary
ConstructorsConstructorDescriptionContractConfig(String precondition, String postcondition, String[] fulfills, Effect[] effects, boolean autoApplyEffects) Creates an instance of aContractConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of theautoApplyEffectsrecord component.Effect[]effects()Returns the value of theeffectsrecord component.final booleanIndicates whether some other object is "equal to" this one.String[]fulfills()Returns the value of thefulfillsrecord component.booleanChecks if any contract element is defined.booleanChecks if effects are defined.booleanChecks if this action fulfills any goals.final inthashCode()Returns a hash code value for this object.booleanChecks if a postcondition is defined.booleanChecks if a precondition is defined.Returns the value of thepostconditionrecord component.Returns the value of thepreconditionrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
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 aContractConfigrecord class.- Parameters:
precondition- the value for thepreconditionrecord componentpostcondition- the value for thepostconditionrecord componentfulfills- the value for thefulfillsrecord componenteffects- the value for theeffectsrecord componentautoApplyEffects- the value for theautoApplyEffectsrecord 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
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
precondition
Returns the value of thepreconditionrecord component.- Returns:
- the value of the
preconditionrecord component
-
postcondition
Returns the value of thepostconditionrecord component.- Returns:
- the value of the
postconditionrecord component
-
fulfills
Returns the value of thefulfillsrecord component.- Returns:
- the value of the
fulfillsrecord component
-
effects
Returns the value of theeffectsrecord component.- Returns:
- the value of the
effectsrecord component
-
autoApplyEffects
public boolean autoApplyEffects()Returns the value of theautoApplyEffectsrecord component.- Returns:
- the value of the
autoApplyEffectsrecord component
-