Skip to content

Commit

Permalink
[ISSUE #509] JreEnum lessThan and greaterThan method
Browse files Browse the repository at this point in the history
  • Loading branch information
KamToHung committed Nov 22, 2024
1 parent 04df36d commit 4b482fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ private static JreEnum getJre() {
* @param targetVersion 目标版本
* @return 是否大于
*/
public boolean greaterThan(JreEnum targetVersion) {
return this.ordinal() > targetVersion.ordinal();
public static boolean greaterThan(JreEnum targetVersion) {
return getJre().ordinal() > targetVersion.ordinal();
}

/**
Expand All @@ -114,8 +114,8 @@ public boolean greaterThan(JreEnum targetVersion) {
* @param targetVersion 目标版本
* @return 是否小于
*/
public boolean lessThan(JreEnum targetVersion) {
return this.ordinal() < targetVersion.ordinal();
public static boolean lessThan(JreEnum targetVersion) {
return getJre().ordinal() < targetVersion.ordinal();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ void testJRE11() {
@Test
@EnabledOnJre(value = JRE.JAVA_11)
void testJRE11GreaterThan() {
Assertions.assertTrue(JreEnum.JAVA_11.greaterThan(JreEnum.JAVA_8));
Assertions.assertTrue(JreEnum.greaterThan(JreEnum.JAVA_8));
}

@Test
@EnabledOnJre(value = JRE.JAVA_8)
void testJRE8LessThan() {
Assertions.assertTrue(JreEnum.JAVA_8.lessThan(JreEnum.JAVA_11));
Assertions.assertTrue(JreEnum.lessThan(JreEnum.JAVA_11));
}

}

0 comments on commit 4b482fd

Please sign in to comment.