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>
TheMetadataVersion
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 aMetadataVersion
instance with identifiers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private int
compareIdentifierArrays(java.lang.String[] otherIdents)
Compares two arrays of identifiers.private int
compareIdentifiers(java.lang.String ident1, java.lang.String ident2)
Compares two identifiers.int
compareTo(MetadataVersion other)
boolean
equals(java.lang.Object other)
private int
getLeastCommonArrayLength(java.lang.String[] arr1, java.lang.String[] arr2)
Returns the size of the smallest array.int
hashCode()
(package private) MetadataVersion
increment()
Increments the metadata version.private boolean
isInt(java.lang.String str)
Checks if the specified string is an integer.java.lang.String
toString()
-
-
-
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
MetadataVersion
class
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
compareTo
public int compareTo(MetadataVersion other)
- Specified by:
compareTo
in 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.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 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.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 orfalse
otherwise
-
-