Package com.github.zafarkhaja.semver
Class MetadataVersion
- java.lang.Object
-
- com.github.zafarkhaja.semver.MetadataVersion
-
- All Implemented Interfaces:
java.lang.Comparable<MetadataVersion>
- Direct Known Subclasses:
MetadataVersion.NullMetadataVersion
class MetadataVersion extends java.lang.Object implements java.lang.Comparable<MetadataVersion>
TheMetadataVersionclass 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 classMetadataVersion.NullMetadataVersionThe implementation of the Null Object design pattern.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String[]identsThe array containing the version's identifiers.(package private) static MetadataVersionNULLNull metadata, the implementation of the Null Object design pattern.
-
Constructor Summary
Constructors Constructor Description MetadataVersion(java.lang.String[] identifiers)Constructs aMetadataVersioninstance with identifiers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private intcompareIdentifierArrays(java.lang.String[] otherIdents)Compares two arrays of identifiers.private intcompareIdentifiers(java.lang.String ident1, java.lang.String ident2)Compares two identifiers.intcompareTo(MetadataVersion other)booleanequals(java.lang.Object other)private intgetLeastCommonArrayLength(java.lang.String[] arr1, java.lang.String[] arr2)Returns the size of the smallest array.inthashCode()(package private) MetadataVersionincrement()Increments the metadata version.private booleanisInt(java.lang.String str)Checks if the specified string is an integer.java.lang.StringtoString()
-
-
-
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.
-
-
Method Detail
-
increment
MetadataVersion increment()
Increments the metadata version.- Returns:
- a new instance of the
MetadataVersionclass
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
compareTo
public int compareTo(MetadataVersion other)
- Specified by:
compareToin interfacejava.lang.Comparable<MetadataVersion>
-
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.compareTomethod
-
getLeastCommonArrayLength
private int getLeastCommonArrayLength(java.lang.String[] arr1, java.lang.String[] arr2)Returns the size of the smallest array.- Parameters:
arr1- the first arrayarr2- 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 identifierident2- the second identifier- Returns:
- integer result of comparison compatible with
the
Comparable.compareTomethod
-
isInt
private boolean isInt(java.lang.String str)
Checks if the specified string is an integer.- Parameters:
str- the string to check- Returns:
trueif the specified string is an integer orfalseotherwise
-
-