Package io.microsphere.util
Class Version
- java.lang.Object
-
- io.microsphere.util.Version
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<Version>
public class Version extends java.lang.Object implements java.lang.Comparable<Version>, java.io.Serializable
The value object to represent a version consisting of major, minor and patch part.- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classVersion.Operator
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Version that)booleaneq(Version that)CurrentVersionis equal to thatbooleanequals(Version that)CurrentVersionis equal to thatbooleanequals(java.lang.Object o)CurrentVersionis equal to thatbooleange(Version that)CurrentVersionis greater than or equal to thatintgetMajor()The major versionintgetMinor()The minor versionintgetPatch()The patchstatic VersiongetVersion(java.lang.Class<?> targetClass)Class that exposes the version.booleangt(Version that)CurrentVersionis greater than thatinthashCode()booleanisGreaterOrEqual(Version that)CurrentVersionis greater than or equal to thatbooleanisGreaterThan(Version that)CurrentVersionis greater than thatbooleanisLessOrEqual(Version that)CurrentVersionis less than or equal to thatbooleanisLessThan(Version that)CurrentVersionis less than thatbooleanle(Version that)CurrentVersionis less than or equal to thatbooleanlt(Version that)CurrentVersionis less than thatstatic Versionof(int major)static Versionof(int major, int minor)static Versionof(int major, int minor, int patch)static Versionof(java.lang.String version)static VersionofVersion(int major)static VersionofVersion(int major, int minor)static VersionofVersion(int major, int minor, int patch)static VersionofVersion(java.lang.String version)java.lang.StringtoString()
-
-
-
Method Detail
-
getMajor
public int getMajor()
The major version- Returns:
- major version
-
getMinor
public int getMinor()
The minor version- Returns:
- minor version
-
getPatch
public int getPatch()
The patch- Returns:
- patch
-
gt
public boolean gt(Version that)
CurrentVersionis greater than that- Parameters:
that- the version to be compared- Returns:
trueif greater than, orfalse- See Also:
isGreaterThan(Version)
-
isGreaterThan
public boolean isGreaterThan(Version that)
CurrentVersionis greater than that- Parameters:
that- the version to be compared- Returns:
trueif greater than, orfalse- See Also:
gt(Version)
-
ge
public boolean ge(Version that)
CurrentVersionis greater than or equal to that- Parameters:
that- the version to be compared- Returns:
trueif greater than, orfalse- See Also:
isGreaterOrEqual(Version)
-
isGreaterOrEqual
public boolean isGreaterOrEqual(Version that)
CurrentVersionis greater than or equal to that- Parameters:
that- the version to be compared- Returns:
trueif greater than, orfalse- See Also:
ge(Version)
-
lt
public boolean lt(Version that)
CurrentVersionis less than that- Parameters:
that- the version to be compared- Returns:
trueif less than, orfalse
-
isLessThan
public boolean isLessThan(Version that)
CurrentVersionis less than that- Parameters:
that- the version to be compared- Returns:
trueif less than, orfalse
-
le
public boolean le(Version that)
CurrentVersionis less than or equal to that- Parameters:
that- the version to be compared- Returns:
trueif less than, orfalse- See Also:
isLessOrEqual(Version)
-
isLessOrEqual
public boolean isLessOrEqual(Version that)
CurrentVersionis less than or equal to that- Parameters:
that- the version to be compared- Returns:
trueif less than, orfalse- See Also:
le(Version)
-
eq
public boolean eq(Version that)
CurrentVersionis equal to that- Parameters:
that- the version to be compared- Returns:
trueif equals, orfalse
-
equals
public boolean equals(Version that)
CurrentVersionis equal to that- Parameters:
that- the version to be compared- Returns:
trueif equals, orfalse
-
equals
public boolean equals(java.lang.Object o)
CurrentVersionis equal to that- Overrides:
equalsin classjava.lang.Object- Parameters:
o- the version to be compared- Returns:
trueif equals, orfalse
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
compareTo
public int compareTo(Version that)
- Specified by:
compareToin interfacejava.lang.Comparable<Version>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
of
public static Version of(int major)
-
of
public static Version of(int major, int minor)
-
of
public static Version of(int major, int minor, int patch)
-
of
public static Version of(java.lang.String version)
-
ofVersion
public static Version ofVersion(int major)
-
ofVersion
public static Version ofVersion(int major, int minor)
-
ofVersion
public static Version ofVersion(int major, int minor, int patch)
-
ofVersion
public static Version ofVersion(java.lang.String version)
-
getVersion
@Nonnull public static Version getVersion(java.lang.Class<?> targetClass) throws java.lang.IllegalArgumentException
Class that exposes the version. Fetches the "Implementation-Version" manifest attribute from the jar file.- Parameters:
targetClass- the class to exposes the version- Returns:
- non-null
- Throws:
java.lang.IllegalArgumentException- if the "Implementation-Version" manifest attribute can't be fetched from the jar file.
-
-