@@ -42,13 +42,21 @@ private TestUtils() {
42
42
* Parses {@param version} and checks whether it is greater or equal to
43
43
* <{@param otherMajor}, {@param otherMinor}, {@param otherPatch}>
44
44
* comparing the corresponding version components in lexicographical order.
45
- *
46
- * @param version
47
- * @param otherMajor
48
- * @param otherMinor
49
- * @param otherPatch
50
45
*/
51
46
public static boolean isAtLeastVersion (final String version , final int otherMajor , final int otherMinor , final int otherPatch ) {
47
+ return compareVersion (version , otherMajor , otherMinor , otherPatch ) >= 0 ;
48
+ }
49
+
50
+ /**
51
+ * Parses {@param version} and checks whether it is less than
52
+ * <{@param otherMajor}, {@param otherMinor}, {@param otherPatch}>
53
+ * comparing the corresponding version components in lexicographical order.
54
+ */
55
+ public static boolean isLessThanVersion (final String version , final int otherMajor , final int otherMinor , final int otherPatch ) {
56
+ return compareVersion (version , otherMajor , otherMinor , otherPatch ) < 0 ;
57
+ }
58
+
59
+ private static int compareVersion (final String version , final int otherMajor , final int otherMinor , final int otherPatch ) {
52
60
String [] parts = version .split ("-" )[0 ].split ("\\ ." );
53
61
54
62
int major = Integer .parseInt (parts [0 ]);
@@ -57,20 +65,15 @@ public static boolean isAtLeastVersion(final String version, final int otherMajo
57
65
58
66
int majorComparison = Integer .compare (major , otherMajor );
59
67
if (majorComparison != 0 ) {
60
- return majorComparison > 0 ;
68
+ return majorComparison ;
61
69
}
62
70
63
71
int minorComparison = Integer .compare (minor , otherMinor );
64
72
if (minorComparison != 0 ) {
65
- return minorComparison > 0 ;
66
- }
67
-
68
- int patchComparison = Integer .compare (patch , otherPatch );
69
- if (patchComparison != 0 ) {
70
- return patchComparison > 0 ;
73
+ return minorComparison ;
71
74
}
72
75
73
- return true ;
76
+ return Integer . compare ( patch , otherPatch ) ;
74
77
}
75
78
76
79
private static String [] generateAllInputChars () {
@@ -90,7 +93,7 @@ private static String[] generateAllInputChars() {
90
93
}
91
94
92
95
public static String generateRandomDbName (int length , boolean extendedNames ) {
93
- if (extendedNames ){
96
+ if (extendedNames ) {
94
97
int max = allChars .length ;
95
98
StringBuilder sb = new StringBuilder ();
96
99
for (int i = 0 ; i < length ; i ++) {
0 commit comments