public class VersionString extends Object
| Modifier and Type | Field and Description |
|---|---|
protected int |
major
Major part of the version.
|
protected int |
minor
Minor part of the version.
|
protected int |
patch
Patch part of the version.
|
protected char |
separator
Separator character for toString.
|
| Constructor and Description |
|---|
VersionString(int major,
int minor,
int patch)
Creates a new version string from integer values.
|
VersionString(String version)
Creates a new version object from a string.
|
| Modifier and Type | Method and Description |
|---|---|
Integer |
getMajor()
Returns the major part of the version.
|
Integer |
getMinor()
Returns the minor part of the version.
|
Integer |
getPatch()
Returns the patch part of the version.
|
void |
setSeparator(char c) |
Map<String,Integer> |
toMap()
Returns the string as a map using the key "major" for the major part, the key "minor" for the minor part and the key "patch" for the patch part.
|
String |
toString() |
protected int major
protected int minor
protected int patch
protected char separator
public VersionString(String version)
version - version string in the format "a.b.c" or "a-b-c" with a, b and c being integers, for instance 0.0.2.
The string will be split, all supported characters are: comma, dot, hyphen and blank; or combinations of them.IllegalArgumentException - if the version string is null or empty or in the wrong formatpublic VersionString(int major,
int minor,
int patch)
major - major part of the versionminor - minor part of the versionpatch - patch part of the versionpublic Integer getMajor()
public Integer getMinor()
public Map<String,Integer> toMap()
public Integer getPatch()
public void setSeparator(char c)
Copyright © 2010–2017. All rights reserved.