@@ -42,13 +42,21 @@ private TestUtils() {
4242 * Parses {@param version} and checks whether it is greater or equal to
4343 * <{@param otherMajor}, {@param otherMinor}, {@param otherPatch}>
4444 * comparing the corresponding version components in lexicographical order.
45- *
46- * @param version
47- * @param otherMajor
48- * @param otherMinor
49- * @param otherPatch
5045 */
5146 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 ) {
5260 String [] parts = version .split ("-" )[0 ].split ("\\ ." );
5361
5462 int major = Integer .parseInt (parts [0 ]);
@@ -57,20 +65,15 @@ public static boolean isAtLeastVersion(final String version, final int otherMajo
5765
5866 int majorComparison = Integer .compare (major , otherMajor );
5967 if (majorComparison != 0 ) {
60- return majorComparison > 0 ;
68+ return majorComparison ;
6169 }
6270
6371 int minorComparison = Integer .compare (minor , otherMinor );
6472 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 ;
7174 }
7275
73- return true ;
76+ return Integer . compare ( patch , otherPatch ) ;
7477 }
7578
7679 private static String [] generateAllInputChars () {
@@ -90,7 +93,7 @@ private static String[] generateAllInputChars() {
9093 }
9194
9295 public static String generateRandomDbName (int length , boolean extendedNames ) {
93- if (extendedNames ){
96+ if (extendedNames ) {
9497 int max = allChars .length ;
9598 StringBuilder sb = new StringBuilder ();
9699 for (int i = 0 ; i < length ; i ++) {
0 commit comments