Class AbstractUID

  • Direct Known Subclasses:
    MetadataKey, UID

    @NonNullByDefault
    public abstract class AbstractUID
    extends Object
    A non specific base class for unique identifiers within the SmartHome framework.
    Author:
    Markus Rathgeb - Initial contribution
    • Constructor Detail

      • AbstractUID

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

        public 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 (must not be null)
      • AbstractUID

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

        public AbstractUID​(List<String> segments)
        Creates a UID for list of segments.
        Parameters:
        segments - segments (must not be null)
    • Method Detail

      • getMinimalNumberOfSegments

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

        protected List<String> getAllSegments()
      • getSegment

        protected String getSegment​(int segment)
      • validateSegment

        protected void validateSegment​(String segment,
                                       int index,
                                       int length)
      • 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