com.faunos.util
Class Version
java.lang.Object
com.faunos.util.Version
- All Implemented Interfaces:
- Comparable<Version>
public class Version
- extends Object
- implements Comparable<Version>
Represents a [software release] version of the form
xx.xx.xx
where xx
is a decimal number
in the range [0, 99]. Provides two mutually compatible serialization
mechanisms:
-
As a
long
: Version(long)
,
toLong()
-
As a
String
: Version(String)
,
toCharSequence()
Both representations are mutually compatible because they are both
exactly 8 bytes wide. The default behavior ignores the separator
character (default is '.'), so there is a many-to-one mapping of serial representations
to logically equal Version
instances.
Constructor Summary |
Version(int major,
int minor,
int sub)
|
Version(int major,
int minor,
int sub,
char separator)
|
Version(long encoded)
|
Version(long encoded,
char separator)
|
Version(long encoded,
char separator,
boolean checkSep)
|
Version(String versionString)
|
DEFAULT_SEPARATOR
public static final char DEFAULT_SEPARATOR
- The default separator ('.').
- See Also:
- Constant Field Values
Version
public Version(int major,
int minor,
int sub)
Version
public Version(int major,
int minor,
int sub,
char separator)
Version
public Version(String versionString)
Version
public Version(long encoded)
Version
public Version(long encoded,
char separator)
Version
public Version(long encoded,
char separator,
boolean checkSep)
getMajor
public final int getMajor()
getMinor
public final int getMinor()
getSub
public final int getSub()
equals
public final boolean equals(Object other)
- Overrides:
equals
in class Object
compareTo
public final int compareTo(Version other)
- Specified by:
compareTo
in interface Comparable<Version>
getSeparator
public char getSeparator()
- Returns the separator character in the string
representation of this instance. The default behavior returns '.'.
- See Also:
DEFAULT_SEPARATOR
toString
public String toString()
- Overrides:
toString
in class Object
toCharSequence
public final CharSequence toCharSequence()
- Returns a string representation of this instance.
- See Also:
Version(String)
toLong
public final long toLong()