Record Class Tag

java.lang.Object
java.lang.Record
net.tangly.core.Tag
Record Components:
namespace - the optional namespace in which the tag is defined
name - the name of the tag
value - the optional value of the tag

public record Tag(String namespace, @NotNull String name, String value) extends Record
The immutable class tag models a tag with a name and a format. Tags provide a powerful approach for multidimensional classifications of values. All fields of a tag are strings. We provide the tag type to support conversions from string values to Java objects.

A tag without a value is equivalent ot a label.

  • Constructor Details

    • Tag

      public Tag(String namespace, @NotNull @NotNull String name, String value)
      Creates an instance of a Tag record class.
      Parameters:
      namespace - the value for the namespace record component
      name - the value for the name record component
      value - the value for the value record component
  • Method Details

    • text

      public static String text(@NotNull @NotNull Collection<Tag> tags)
      Transforms a collection of tags into their canonical textual representation.
      Parameters:
      tags - tags to be transformed
      Returns:
      textual representation of the tags
      See Also:
    • toTags

      public static Set<Tag> toTags(String rawTags)
      Transforms raw tags textual representation into a set of tags.
      Parameters:
      rawTags - textual representation of tags
      Returns:
      set of the tag instances
      See Also:
    • namespace

      public static String namespace(@NotNull @NotNull String tag)
    • name

      public static String name(@NotNull @NotNull String tag)
    • value

      public static String value(@NotNull @NotNull String tag)
    • parse

      public static Tag parse(String tag)
    • ofEmpty

      public static Tag ofEmpty(String namespace, @NotNull @NotNull String name)
    • ofEmpty

      public static Tag ofEmpty(@NotNull @NotNull String name)
    • of

      public static Tag of(@NotNull @NotNull String tag, String value)
    • of

      public static Tag of(String namespace, @NotNull @NotNull String name, String value)
    • hasValue

      public boolean hasValue()
      Return true if the tag has a format otherwise false.
      Returns:
      flag indicating if the tag has a format field
    • text

      public String text()
    • 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.
    • namespace

      public String namespace()
      Returns the value of the namespace record component.
      Returns:
      the value of the namespace record component
    • name

      @NotNull public @NotNull String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • value

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