Package com.tnsai.communication
Class AgentMessage
java.lang.Object
com.tnsai.communication.AgentMessage
Represents a message between agents.
Immutable value object for thread-safe communication.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AgentMessagecreate(String senderId, String receiverId, MessageTypeMarker messageType, Map<String, Object> content) Creates a new message with auto-generated ID and timestamp.static AgentMessagecreateReply(AgentMessage originalMessage, MessageTypeMarker replyType, Map<String, Object> content) Creates a reply to this message (swaps sender and receiver).getSpec()Gets the message spec (metadata).booleanisCategory(String category) Check if message belongs to a specific category (CNP, TASK, etc.)booleanisReply()Checks if this message is a reply to another message.booleanisType(MessageTypeMarker type) Check if message is of a specific type.Creates a new message with additional metadata.
-
Constructor Details
-
AgentMessage
-
-
Method Details
-
create
public static AgentMessage create(String senderId, String receiverId, MessageTypeMarker messageType, Map<String, Object> content) Creates a new message with auto-generated ID and timestamp. -
createReply
public static AgentMessage createReply(AgentMessage originalMessage, MessageTypeMarker replyType, Map<String, Object> content) Creates a reply to this message (swaps sender and receiver). -
withSpec
Creates a new message with additional metadata. -
getSpec
Gets the message spec (metadata). This is an alias for getMetadata() following the spec naming convention.- Returns:
- immutable map of spec data
-
isReply
public boolean isReply()Checks if this message is a reply to another message. -
isType
Check if message is of a specific type. -
isCategory
Check if message belongs to a specific category (CNP, TASK, etc.)
-