Package com.github.zafarkhaja.semver
Class MetadataVersion
java.lang.Object
com.github.zafarkhaja.semver.MetadataVersion
- All Implemented Interfaces:
Comparable<MetadataVersion>
- Direct Known Subclasses:
MetadataVersion.NullMetadataVersion
The
MetadataVersion
class is used to represent
the pre-release version and the build metadata.- Since:
- 0.2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
The implementation of the Null Object design pattern. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String[]
The array containing the version's identifiers.(package private) static final MetadataVersion
Null metadata, the implementation of the Null Object design pattern. -
Constructor Summary
ConstructorsConstructorDescriptionMetadataVersion
(String[] identifiers) Constructs aMetadataVersion
instance with identifiers. -
Method Summary
Modifier and TypeMethodDescriptionprivate int
compareIdentifierArrays
(String[] otherIdents) Compares two arrays of identifiers.private int
compareIdentifiers
(String ident1, String ident2) Compares two identifiers.int
compareTo
(MetadataVersion other) boolean
private int
getLeastCommonArrayLength
(String[] arr1, String[] arr2) Returns the size of the smallest array.int
hashCode()
(package private) MetadataVersion
Increments the metadata version.private boolean
Checks if the specified string is an integer.toString()
-
Field Details
-
NULL
Null metadata, the implementation of the Null Object design pattern. -
idents
The array containing the version's identifiers.
-
-
Constructor Details
-
MetadataVersion
MetadataVersion(String[] identifiers) Constructs aMetadataVersion
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
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<MetadataVersion>
-
compareIdentifierArrays
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
Returns the size of the smallest array.- Parameters:
arr1
- the first arrayarr2
- the second array- Returns:
- the size of the smallest array
-
compareIdentifiers
Compares two identifiers.- Parameters:
ident1
- the first identifierident2
- the second identifier- Returns:
- integer result of comparison compatible with
the
Comparable.compareTo
method
-
isInt
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
-