Class TagValue

  • Direct Known Subclasses:
    AutoValue_TagValue

    @Immutable
    public abstract class TagValue
    extends java.lang.Object
    A validated tag value.

    Validation ensures that the String has a maximum length of MAX_LENGTH and contains only printable ASCII characters.

    Since:
    0.8
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_LENGTH
      The maximum length for a tag value.
    • Constructor Summary

      Constructors 
      Constructor Description
      TagValue()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract java.lang.String asString()
      Returns the tag value as a String.
      static TagValue create​(java.lang.String value)
      Constructs a TagValue from the given string.
      private static boolean isValid​(java.lang.String value)
      Determines whether the given String is a valid tag value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MAX_LENGTH

        public static final int MAX_LENGTH
        The maximum length for a tag value. The value is 255.
        Since:
        0.8
        See Also:
        Constant Field Values
    • Constructor Detail

      • TagValue

        TagValue()
    • Method Detail

      • create

        public static TagValue create​(java.lang.String value)
        Constructs a TagValue from the given string. The string must meet the following requirements:
        1. It cannot be longer than MAX_LENGTH.
        2. It can only contain printable ASCII characters.
        Parameters:
        value - the tag value.
        Throws:
        java.lang.IllegalArgumentException - if the String is not valid.
        Since:
        0.8
      • asString

        public abstract java.lang.String asString()
        Returns the tag value as a String.
        Returns:
        the tag value as a String.
        Since:
        0.8
      • isValid

        private static boolean isValid​(java.lang.String value)
        Determines whether the given String is a valid tag value.
        Parameters:
        value - the tag value to be validated.
        Returns:
        whether the value is valid.