Record Class DIDConfig

java.lang.Object
java.lang.Record
com.tnsai.identity.DIDConfig

public record DIDConfig(String method, String domain, String agentId, String publicKey, String keyType, boolean generateDocument, String serviceEndpoint) extends Record
Programmatic counterpart of DIDSpec — the configuration an agent declares to derive its DID (and, where supported, a DIDDocument).

Where DID is the representation (the did: string plus its parsed components), DIDConfig is the configuration: the inputs an agent supplies — via @AgentSpec(did = ...) or AgentBuilder.did(DIDConfig) — that those components are derived from. The annotation and builder paths share this value type so both produce identical DIDs (see toDid(String)).

Since:
0.11.0
Author:
TnsAI Team
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    DIDConfig(String method, String domain, String agentId, String publicKey, String keyType, boolean generateDocument, String serviceEndpoint)
    Normalizes nulls to the same defaults the annotation declares so the record never carries null string fields.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the agentId record component.
    Returns the value of the domain record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    static DIDConfig
    from(DIDSpec annotation)
    Builds a config from a DIDSpec annotation (1:1 field mapping).
    boolean
    Returns the value of the generateDocument record component.
    final int
    Returns a hash code value for this object.
    Returns the value of the keyType record component.
    Returns the value of the method record component.
    static DIDConfig
    of(String method, String domain, String agentId)
    Convenience factory for the common case — method, domain and agent id, with the remaining fields left at their defaults.
    Returns the value of the publicKey record component.
    Returns the value of the serviceEndpoint record component.
    toDid(String fallbackAgentId)
    Resolves this config to a DID string, applying the same default substitution as the annotation path: empty method → wba, empty domain → local, empty agent id → fallbackAgentId.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DIDConfig

      public DIDConfig(String method, String domain, String agentId, String publicKey, String keyType, boolean generateDocument, String serviceEndpoint)
      Normalizes nulls to the same defaults the annotation declares so the record never carries null string fields.
  • Method Details

    • from

      public static DIDConfig from(DIDSpec annotation)
      Builds a config from a DIDSpec annotation (1:1 field mapping).
      Parameters:
      annotation - the @DIDSpec to read
      Returns:
      the equivalent programmatic config
    • of

      public static DIDConfig of(String method, String domain, String agentId)
      Convenience factory for the common case — method, domain and agent id, with the remaining fields left at their defaults.
      Parameters:
      method - DID method (e.g. wba)
      domain - domain (e.g. example.com)
      agentId - method-specific agent id
      Returns:
      a config with default keyType, generateDocument = true
    • toDid

      public String toDid(String fallbackAgentId)
      Resolves this config to a DID string, applying the same default substitution as the annotation path: empty method → wba, empty domain → local, empty agent id → fallbackAgentId.
      Parameters:
      fallbackAgentId - agent id used when agentId() is blank
      Returns:
      a did:method:domain:id string
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • method

      public String method()
      Returns the value of the method record component.
      Returns:
      the value of the method record component
    • domain

      public String domain()
      Returns the value of the domain record component.
      Returns:
      the value of the domain record component
    • agentId

      public String agentId()
      Returns the value of the agentId record component.
      Returns:
      the value of the agentId record component
    • publicKey

      public String publicKey()
      Returns the value of the publicKey record component.
      Returns:
      the value of the publicKey record component
    • keyType

      public String keyType()
      Returns the value of the keyType record component.
      Returns:
      the value of the keyType record component
    • generateDocument

      public boolean generateDocument()
      Returns the value of the generateDocument record component.
      Returns:
      the value of the generateDocument record component
    • serviceEndpoint

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