Class MetadataVersion

java.lang.Object
com.github.zafarkhaja.semver.MetadataVersion
All Implemented Interfaces:
Comparable<MetadataVersion>
Direct Known Subclasses:
MetadataVersion.NullMetadataVersion

class MetadataVersion extends Object implements Comparable<MetadataVersion>
The MetadataVersion class is used to represent the pre-release version and the build metadata.
Since:
0.2.0
  • Field Details

    • NULL

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

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

    • MetadataVersion

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

    • increment

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

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

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

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

      public int compareTo(MetadataVersion other)
      Specified by:
      compareTo in interface Comparable<MetadataVersion>
    • compareIdentifierArrays

      private int compareIdentifierArrays(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(String[] arr1, 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(String ident1, 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(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