Class TypedString<T extends TypedString<T>>

    • Constructor Detail

      • TypedString

        protected TypedString​(String name)
        Creates an instance.
        Parameters:
        name - the name, not empty
      • TypedString

        protected TypedString​(String name,
                              Pattern pattern,
                              String msg)
        Creates an instance, validating the name against a regex.

        In most cases, a CharMatcher will be faster than a regex Pattern, typically by over an order of magnitude.

        Parameters:
        name - the name, not empty
        pattern - the regex pattern for validating the name
        msg - the message to use to explain validation failure
      • TypedString

        protected TypedString​(String name,
                              CharMatcher matcher,
                              String msg)
        Creates an instance, validating the name against a matcher.

        In most cases, a CharMatcher will be faster than a regex Pattern, typically by over an order of magnitude.

        Parameters:
        name - the name, not empty
        matcher - the matcher for validating the name
        msg - the message to use to explain validation failure
    • Method Detail

      • getName

        public String getName()
        Gets the name.
        Specified by:
        getName in interface Named
        Returns:
        the name
      • compareTo

        public final int compareTo​(T other)
        Compares this type to another.

        Instances are compared in alphabetical order based on the name.

        Specified by:
        compareTo in interface Comparable<T extends TypedString<T>>
        Parameters:
        other - the object to compare to
        Returns:
        the comparison
      • equals

        public final boolean equals​(Object obj)
        Checks if this type equals another.

        Instances are compared based on the name.

        Overrides:
        equals in class Object
        Parameters:
        obj - the object to compare to, null returns false
        Returns:
        true if equal
      • hashCode

        public final int hashCode()
        Returns a suitable hash code.
        Overrides:
        hashCode in class Object
        Returns:
        a suitable hash code
      • toString

        public final String toString()
        Returns the name.
        Overrides:
        toString in class Object
        Returns:
        the string form, not empty