Class AgentMessage

java.lang.Object
com.tnsai.communication.AgentMessage

public final class AgentMessage extends Object
Represents a message between agents. Immutable value object for thread-safe communication.
  • Constructor Details

  • 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

      public AgentMessage withSpec(String key, Object value)
      Creates a new message with additional metadata.
    • getSpec

      public Map<String,Object> 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

      public boolean isType(MessageTypeMarker type)
      Check if message is of a specific type.
    • isCategory

      public boolean isCategory(String category)
      Check if message belongs to a specific category (CNP, TASK, etc.)