Class MetadataVersion

  • All Implemented Interfaces:
    java.lang.Comparable<MetadataVersion>
    Direct Known Subclasses:
    MetadataVersion.NullMetadataVersion

    class MetadataVersion
    extends java.lang.Object
    implements java.lang.Comparable<MetadataVersion>
    The MetadataVersion class is used to represent the pre-release version and the build metadata.
    Since:
    0.2.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  MetadataVersion.NullMetadataVersion
      The implementation of the Null Object design pattern.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String[] idents
      The array containing the version's identifiers.
      (package private) static MetadataVersion NULL
      Null metadata, the implementation of the Null Object design pattern.
    • Constructor Summary

      Constructors 
      Constructor Description
      MetadataVersion​(java.lang.String[] identifiers)
      Constructs a MetadataVersion instance with identifiers.
    • Field Detail

      • NULL

        static final MetadataVersion NULL
        Null metadata, the implementation of the Null Object design pattern.
      • idents

        private final java.lang.String[] idents
        The array containing the version's identifiers.
    • Constructor Detail

      • MetadataVersion

        MetadataVersion​(java.lang.String[] identifiers)
        Constructs a MetadataVersion instance with identifiers.
        Parameters:
        identifiers - the version's identifiers
    • Method Detail

      • increment

        MetadataVersion increment()
        Increments the metadata version.
        Returns:
        a new instance of the MetadataVersion class
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • compareIdentifierArrays

        private int compareIdentifierArrays​(java.lang.String[] otherIdents)
        Compares two arrays of identifiers.
        Parameters:
        otherIdents - the identifiers of the other version
        Returns:
        integer result of comparison compatible with the Comparable.compareTo method
      • getLeastCommonArrayLength

        private int getLeastCommonArrayLength​(java.lang.String[] arr1,
                                              java.lang.String[] arr2)
        Returns the size of the smallest array.
        Parameters:
        arr1 - the first array
        arr2 - the second array
        Returns:
        the size of the smallest array
      • compareIdentifiers

        private int compareIdentifiers​(java.lang.String ident1,
                                       java.lang.String ident2)
        Compares two identifiers.
        Parameters:
        ident1 - the first identifier
        ident2 - the second identifier
        Returns:
        integer result of comparison compatible with the Comparable.compareTo method
      • isInt

        private boolean isInt​(java.lang.String str)
        Checks if the specified string is an integer.
        Parameters:
        str - the string to check
        Returns:
        true if the specified string is an integer or false otherwise