Record Class MqttTopic

java.lang.Object
java.lang.Record
energy.eddie.regionconnector.aiida.mqtt.MqttTopic

public record MqttTopic(String prefix, String permissionId, MqttTopicType topicType) extends Record
  • Constructor Details

    • MqttTopic

      public MqttTopic(String prefix, String permissionId, MqttTopicType topicType)
      Creates an instance of a MqttTopic record class.
      Parameters:
      prefix - the value for the prefix record component
      permissionId - the value for the permissionId record component
      topicType - the value for the topicType record component
  • Method Details

    • of

      public static MqttTopic of(String permissionId, MqttTopicType topicType)
    • extractPermissionIdFromTopic

      public static String extractPermissionIdFromTopic(String topicStr, MqttTopicType topicType, @Nullable AiidaSchema schema) throws MqttTopicException
      Extracts the permissionId from an MQTT topic.

      The expected topic format depends on whether a schema is provided:

      • Without schema: aiida/v1/{permissionId}/{baseTopicName}
      • With schema: aiida/v1/{permissionId}/{baseTopicName}/{schemaTopic}

      The baseTopicName is derived from the given MqttTopicType, and the optional schema suffix is taken from AiidaSchema.topicName().

      Parameters:
      topicStr - the MQTT topic string to parse
      topicType - the expected topic type (defines the base topic segment)
      schema - the schema used for this topic, or null if no schema suffix is expected
      Returns:
      the extracted permissionId
      Throws:
      MqttTopicException - if the topic does not conform to the expected pattern
    • eddieTopic

      public String eddieTopic()
    • aiidaTopic

      public String aiidaTopic()
    • baseTopic

      public String baseTopic()
    • aiidaAcl

      public MqttAcl aiidaAcl(String username)
    • 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.
    • prefix

      public String prefix()
      Returns the value of the prefix record component.
      Returns:
      the value of the prefix record component
    • permissionId

      public String permissionId()
      Returns the value of the permissionId record component.
      Returns:
      the value of the permissionId record component
    • topicType

      public MqttTopicType topicType()
      Returns the value of the topicType record component.
      Returns:
      the value of the topicType record component