public class SemVer extends Object implements Comparable<SemVer>
Cet objet est immutable, Il faut utiliser getCreator()
pour modifier un de ses elements
Quelques changements par rapport au site :
| Modifier and Type | Class and Description |
|---|---|
static class |
SemVer.SemVerCreator
Construit un objet version, la verification de la coherence est faite lors
de l'appel du create.
|
| Modifier and Type | Field and Description |
|---|---|
protected String |
build |
static String |
BUILD_SEPARATOR
Séparateur utiliser devant l'élément build
|
static String |
PATTERN_BUILD
Pattern pour une partie de l'élément build
|
static String |
PATTERN_PRERELEASE
Pattern pour une partie de l'élément prerelease
|
static String |
PATTERN_VERSION
Pattern pour une partie de l'élément version
|
protected String |
prerelease |
static String |
PRERELEASE_SEPARATOR
Séparateur entre la version et l'élément prerelease
|
static String |
SERIES_SEPARATOR
Séparateur utilisé entre chaque element d'une partie
|
protected String |
snapshot |
static String |
SNAPSHOT
La chaine de caractère représentant le SNAPSHOT
|
static String |
SNAPSHOT_SEPARATOR
Séparateur de SNAPSHOT
|
protected String |
version |
| Constructor and Description |
|---|
SemVer(String versionString)
Create new Version object, strip is done on argument to remove extra space
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
after(SemVer o) |
boolean |
before(SemVer o) |
protected int |
compare(String a,
String b,
boolean nullIsHigh)
Compare deux elements de meme semantique (version, prerelease, build, snapshot)
sinon le comportement est non predictible
|
int |
compareTo(SemVer other) |
static SemVer.SemVerCreator |
creator()
Retourne un Créateur sans aucune information.
|
static SemVer.SemVerCreator |
creator(int... v)
Créateur qui permet de passer en paramètre les différentes composantes de l'élément version
|
static SemVer.SemVerCreator |
creator(SemVer v)
Create creator initialized with SemVer value, you can change some Element
by putting null value.
|
static SemVer.SemVerCreator |
creator(String... v)
Permet de creer un objet version.
|
boolean |
equals(Object o) |
String |
getBuild() |
String |
getBuild(int i)
Retourne un des composants de l'élément version
|
int |
getBuildCount()
Donne le nombre de composantes de la Prerelease
1.2.3 retourne 3
99.100 retourne 2
|
protected String |
getComposant(String element,
int i)
Retourne un des composants de l'élément version
|
protected int |
getComposantCount(String element)
Donne le nombre de composantes de l'élément
1.2.3 retourne 3
99.100 retourne 2
|
SemVer.SemVerCreator |
getCreator()
Retourne un objet creator initialise avec les donnees de ce SemVer
ce qui permet de créer un nouveau SemVer en modifiant un des elements
|
String |
getMajor() |
String |
getMinor() |
String |
getPatch() |
String |
getPrerelease() |
String |
getPrerelease(int i)
Retourne un des composants de l'élément version
|
int |
getPrereleaseCount()
Donne le nombre de composantes de la Prerelease
1.2.3 retourne 3
99.100 retourne 2
|
String |
getSnapshot() |
String |
getVersion() |
String |
getVersion(int i)
Retourne un des composants de l'élément version
|
int |
getVersionCount()
Donne le nombre de composantes de la version
1.2.3 retourne 3
99.100 retourne 2
|
int |
hashCode() |
protected static String |
ifNotNull(String prefix,
String s) |
static boolean |
isSemVer(String version)
Indique si la chaine represente bien une version au format SemVer
|
boolean |
isSnapshot() |
protected int |
nullIsHigh(String a,
String b)
Ne compare pas la chaine, seulement la nullité, si un des arguments
est null, alors il est plus grand que l'autre.
|
protected int |
nullIsLow(String a,
String b)
Ne compare pas la chaine, seulement la nullite, si un des arguments
est null, alors il est plus petit que l'autre.
|
String |
toJavaIdentifier()
Convertit la representation textuelle de la version en identifiant java valide :
- en java : "-" "." "+" interdit
|
String |
toString() |
public static final String SERIES_SEPARATOR
public static final String PRERELEASE_SEPARATOR
public static final String BUILD_SEPARATOR
public static final String PATTERN_VERSION
public static final String PATTERN_PRERELEASE
public static final String PATTERN_BUILD
public static final String SNAPSHOT_SEPARATOR
public static final String SNAPSHOT
protected String version
protected String prerelease
protected String build
protected String snapshot
public SemVer(String versionString)
versionString - FIXMEIllegalArgumentException - if argument isn't valid version stringpublic boolean before(SemVer o)
o - the other version to testtrue if current version is before the given onepublic boolean after(SemVer o)
o - the other version to testtrue if current version is after the given onepublic int compareTo(SemVer other)
compareTo in interface Comparable<SemVer>protected int compare(String a, String b, boolean nullIsHigh)
a - FIXMEb - FIXMEnullIsHigh - indique si un des elements est null, s'il est plus
grand ou plus petit que l'autrea < b, 0 si a == b, positif si a > bprotected int nullIsHigh(String a, String b)
1.0 est plus grand que 1.0-Beta
a - FIXMEb - FIXMEprotected int nullIsLow(String a, String b)
1.0+r123 est plus grand que 1.0
a - FIXMEb - FIXMEprotected int getComposantCount(String element)
element - FIXMEprotected String getComposant(String element, int i)
element - FIXMEi - FIXMEpublic String getVersion()
public int getVersionCount()
public String getVersion(int i)
i - FIXMEpublic String getMajor()
public String getMinor()
public String getPatch()
public String getPrerelease()
public int getPrereleaseCount()
public String getPrerelease(int i)
i - FIXMEpublic String getBuild()
public int getBuildCount()
public String getBuild(int i)
i - FIXMEpublic String getSnapshot()
public boolean isSnapshot()
public String toJavaIdentifier()
public SemVer.SemVerCreator getCreator()
public static boolean isSemVer(String version)
version - FIXMEpublic static SemVer.SemVerCreator creator(String... v)
SemVer v = SemVer.creator().setVersion("1.2").setPrerelease("beta.1").setBuild("r123").done();
SemVer v = SemVer.creator("1.2", "beta.1","r123", SemVer.SNAPSHOT).done();
v - FIXMEpublic static SemVer.SemVerCreator creator(int... v)
v - FIXMEpublic static SemVer.SemVerCreator creator(SemVer v)
SemVer n = SemVer.creator(v).setBuild("r123").setSnapshot(false).done();
v - FIXMEpublic static SemVer.SemVerCreator creator()
Copyright © 2016–2026 Code Lutin. All rights reserved.