Class AbstractUID

java.lang.Object
org.openhab.core.common.AbstractUID
Direct Known Subclasses:
MetadataKey, UID

@NonNullByDefault public abstract class AbstractUID extends Object
A non specific base class for unique identifiers.
Author:
Markus Rathgeb - Initial contribution
  • Field Details

  • Constructor Details

    • AbstractUID

      protected AbstractUID()
      Constructor must be protected, otherwise it can not be called by subclasses from another package.
    • AbstractUID

      protected AbstractUID(String uid)
      Parses a UID for a given string. The UID must be in the format 'bindingId:segment:segment:...'.
      Parameters:
      uid - uid in form a string
    • AbstractUID

      protected AbstractUID(String... segments)
      Creates an AbstractUID for a list of segments.
      Parameters:
      segments - the id segments
    • AbstractUID

      protected AbstractUID(List<String> segments)
      Creates a UID for list of segments.
      Parameters:
      segments - segments
  • Method Details

    • getMinimalNumberOfSegments

      protected abstract int getMinimalNumberOfSegments()
      Specifies how many segments the UID has to have at least.
      Returns:
      the number of segments
    • getAllSegments

      protected List<String> getAllSegments()
    • getSegment

      protected String getSegment(int segment)
    • isValid

      public static boolean isValid(@Nullable String segment)
    • validateSegment

      protected void validateSegment(String segment, int index, int length)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getAsString

      public String getAsString()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object