Package com.tnsai.context.decision
Record Class DecisionTrigger
java.lang.Object
java.lang.Record
com.tnsai.context.decision.DecisionTrigger
public record DecisionTrigger(DecisionTrigger.TriggerType type, String description, String source, Instant timestamp, Map<String,Object> context)
extends Record
Represents what initiated a decision.
DecisionTrigger captures the event or condition that led to the agent making a decision. This enables understanding the causal chain leading to agent actions.
Usage Example
DecisionTrigger trigger = DecisionTrigger.userRequest(
"Process discount request",
"user-123"
);
// Or from a system event
DecisionTrigger eventTrigger = DecisionTrigger.systemEvent(
"account.status.changed",
Map.of("oldStatus", "active", "newStatus", "suspended")
);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumType of trigger that initiated the decision. -
Constructor Summary
ConstructorsConstructorDescriptionDecisionTrigger(DecisionTrigger.TriggerType type, String description, String source, Instant timestamp, Map<String, Object> context) Compact constructor with validation. -
Method Summary
Modifier and TypeMethodDescriptionstatic DecisionTriggeragentRequest(String description, String agentId) Creates a trigger from another agent.static DecisionTriggerbeliefChange(String beliefDescription, String changeType) Creates a trigger from a belief change.context()Returns the value of thecontextrecord component.Returns the value of thedescriptionrecord component.final booleanIndicates whether some other object is "equal to" this one.static DecisionTriggergoalActivation(String goalDescription) Creates a trigger from a goal activation.final inthashCode()Returns a hash code value for this object.booleanReturns true if this trigger was from the system.booleanReturns true if this trigger was from a user.static DecisionTriggerCreates a manual trigger for debugging/testing.static DecisionTriggerCreates a trigger from a scheduled task.source()Returns the value of thesourcerecord component.static DecisionTriggersystemEvent(String eventType, Map<String, Object> context) Creates a trigger from a system event.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.static DecisionTriggeruserRequest(String description, String userId) Creates a trigger from a user request.
-
Constructor Details
-
Method Details
-
userRequest
Creates a trigger from a user request.- Parameters:
description- what the user requesteduserId- user identifier- Returns:
- new DecisionTrigger
-
systemEvent
Creates a trigger from a system event.- Parameters:
eventType- event type identifiercontext- event context data- Returns:
- new DecisionTrigger
-
scheduled
Creates a trigger from a scheduled task.- Parameters:
taskName- name of the scheduled task- Returns:
- new DecisionTrigger
-
agentRequest
Creates a trigger from another agent.- Parameters:
description- what the agent requestedagentId- requesting agent identifier- Returns:
- new DecisionTrigger
-
goalActivation
Creates a trigger from a goal activation.- Parameters:
goalDescription- description of the goal- Returns:
- new DecisionTrigger
-
beliefChange
Creates a trigger from a belief change.- Parameters:
beliefDescription- description of the changed beliefchangeType- type of change (added, modified, removed)- Returns:
- new DecisionTrigger
-
manual
Creates a manual trigger for debugging/testing.- Parameters:
description- description of the manual trigger- Returns:
- new DecisionTrigger
-
isUserInitiated
public boolean isUserInitiated()Returns true if this trigger was from a user. -
isSystemInitiated
public boolean isSystemInitiated()Returns true if this trigger was from the system. -
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. All components in this record class are compared withObjects::equals(Object,Object). -
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
description
Returns the value of thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord component
-
source
Returns the value of thesourcerecord component.- Returns:
- the value of the
sourcerecord component
-
timestamp
Returns the value of thetimestamprecord component.- Returns:
- the value of the
timestamprecord component
-
context
Returns the value of thecontextrecord component.- Returns:
- the value of the
contextrecord component
-