Record Class PrincipalRef

java.lang.Object
java.lang.Record
io.meeds.mcp.server.model.PrincipalRef
Record Components:
kind - whether the account is a person's or an agent's
username - the account's login, never blank
agentNameId - the agent the account belongs to, set for PrincipalKind.AGENT only

public record PrincipalRef(PrincipalKind kind, String username, String agentNameId) extends Record
The platform account that executes a tool call: a person's, or an agent's own account. An agent account also names the agent it is the account of.
  • Constructor Details

    • PrincipalRef

      public PrincipalRef(PrincipalKind kind, String username, String agentNameId)
      Checks the reference is complete and consistent: a kind, a login, and an agent name id exactly when the account is an agent's.
      Parameters:
      kind - whether the account is a person's or an agent's
      username - the account's login
      agentNameId - the agent the account belongs to, for an agent only
      Throws:
      IllegalArgumentException - when a part is missing or does not fit the kind
  • Method Details

    • user

      public static PrincipalRef user(String username)
      Parameters:
      username - a person's login
      Returns:
      the reference of that person's account
    • agent

      public static PrincipalRef agent(String username, String agentNameId)
      Parameters:
      username - an agent account's login
      agentNameId - the agent it is the account of
      Returns:
      the reference of that agent account
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • kind

      public PrincipalKind kind()
      Returns the value of the kind record component.
      Returns:
      the value of the kind record component
    • username

      public String username()
      Returns the value of the username record component.
      Returns:
      the value of the username record component
    • agentNameId

      public String agentNameId()
      Returns the value of the agentNameId record component.
      Returns:
      the value of the agentNameId record component