Package com.avoka.fc.core.util
Class VersionNumberComparator
- java.lang.Object
-
- com.avoka.fc.core.util.VersionNumberComparator
-
- All Implemented Interfaces:
Comparator<String>
public class VersionNumberComparator extends Object implements Comparator<String>
Provides a comparator for version numbers in the format a.b.c (e.g. 3.6.0). Up to four levels are supported (e.g. 4.0.0.1). If less than 4 levels are used, unused levels are assumed to be 0 (e.g. 1.5 is treated internally as 1.5.0.0)- Since:
- 4.0.0
-
-
Constructor Summary
Constructors Constructor Description VersionNumberComparator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(String value1, String value2)
Compares two version numbers in the format a.b.c (e.g.-
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
-
-
-
-
Method Detail
-
compare
public int compare(String value1, String value2)
Compares two version numbers in the format a.b.c (e.g. 3.6.0). Up to four levels are supported (e.g. 4.0.0.1). If less than 4 levels are used, unused levels are assumed to be 0 (e.g. 1.5 is treated internally as 1.5.0.0). Null version numbers are treated as being "less than" other version numbers. Note: If version numbers use non-numeric components on the significant levels (e.g. 3.6a), the comparator will fail. You have been warned.- Specified by:
compare
in interfaceComparator<String>
- Parameters:
value1
- the first version number stringvalue2
- the second version number string- Returns:
- -1, 0 or 1 if the first version number is less than, equal to or greater than the second version number
-
-