Package io.smallrye.common.version
Class AbstractVersionScheme<I extends AbstractVersionIterator>
- java.lang.Object
-
- io.smallrye.common.version.AbstractVersionScheme<I>
-
- All Implemented Interfaces:
VersionScheme,Comparator<String>
public abstract class AbstractVersionScheme<I extends AbstractVersionIterator> extends Object implements VersionScheme
A version scheme base class that provides basic comparison functionality.
-
-
Field Summary
-
Fields inherited from interface io.smallrye.common.version.VersionScheme
BASIC, JPMS, MAVEN
-
-
Constructor Summary
Constructors Constructor Description AbstractVersionScheme()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringBuilderappendCanonicalized(StringBuilder target, String original)Append the canonical representation of this version to the given builder, according to the current version scheme.protected abstract intcompare(I i1, I i2)Compare the current tokens of the two given iterators.intcompare(String v1, String v2)Compare two versions according to this version scheme.protected intcompareNext(I i1, I i2)Compare the next elements of the given iterators.abstract Iiterate(String version)Iterate the canonicalized components of the given version according to the rules of this versioning scheme.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from interface io.smallrye.common.version.VersionScheme
canonicalize, equals, validate
-
-
-
-
Method Detail
-
compare
public int compare(String v1, String v2)
Description copied from interface:VersionSchemeCompare two versions according to this version scheme.- Specified by:
comparein interfaceComparator<I extends AbstractVersionIterator>- Specified by:
comparein interfaceVersionScheme- Parameters:
v1- the first version (must not benull)v2- the second version (must not benull)- Returns:
-1,0, or1if the first version is less than, equal to, or greater than the second version according to this version scheme
-
iterate
public abstract I iterate(String version)
Description copied from interface:VersionSchemeIterate the canonicalized components of the given version according to the rules of this versioning scheme.- Specified by:
iteratein interfaceVersionScheme- Parameters:
version- the version to iterate (must not benull)- Returns:
- the version iterator (not
null)
-
appendCanonicalized
public StringBuilder appendCanonicalized(StringBuilder target, String original)
Description copied from interface:VersionSchemeAppend the canonical representation of this version to the given builder, according to the current version scheme.- Specified by:
appendCanonicalizedin interfaceVersionScheme- Parameters:
target- the string builder to append to (must not benull)original- the possibly non-canonical version (must not benull)- Returns:
- the string builder that was passed in
-
compareNext
protected int compareNext(I i1, I i2)
Compare the next elements of the given iterators. If one iterator is at the end of iteration (its iterator reports no next element), the corresponding version is considered to come before the other version. If both iterators are at the end of iteration, the versions are considered equal. Otherwise,compare(I, I)is called to compare the iterators' current tokens.- Parameters:
i1- the iterator for the first version (must not benull)i2- the iterator for the second version (must not benull)- Returns:
-1,0, or1if the first version is less than, equal to, or greater than the second version
-
compare
protected abstract int compare(I i1, I i2)
Compare the current tokens of the two given iterators. If the tokens are equal, then this method should recurse tocompareNext(I, I)(or equivalent) to compare the next tokens.- Parameters:
i1- the iterator for the first version (must not benull)i2- the iterator for the second version (must not benull)- Returns:
-1,0, or1if the first version is less than, equal to, or greater than the second version
-
-