diff --git a/common/src/main/java/org/dromara/dynamictp/common/em/JreEnum.java b/common/src/main/java/org/dromara/dynamictp/common/em/JreEnum.java index 859da958e..ca4e60552 100644 --- a/common/src/main/java/org/dromara/dynamictp/common/em/JreEnum.java +++ b/common/src/main/java/org/dromara/dynamictp/common/em/JreEnum.java @@ -23,6 +23,7 @@ /** * JRE version + * * @author kamtohung */ @Slf4j @@ -97,4 +98,24 @@ private static JreEnum getJre() { return JAVA_8; } + /** + * 判断当前版本是否大于某个版本 + * + * @param targetVersion 目标版本 + * @return 是否大于 + */ + public static boolean greaterThan(JreEnum targetVersion) { + return getJre().ordinal() > targetVersion.ordinal(); + } + + /** + * 判断当前版本是否小于某个版本 + * + * @param targetVersion 目标版本 + * @return 是否小于 + */ + public static boolean lessThan(JreEnum targetVersion) { + return getJre().ordinal() < targetVersion.ordinal(); + } + } diff --git a/pom.xml b/pom.xml index b74620f64..ac8d80741 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,9 @@ pom DynamicTp Project - 🔥🔥🔥轻量级动态线程池,内置监控告警功能,基于主流配置中心(已支持Nacos、Apollo、Zookeeper、Consul、Etcd、Polaris,可通过SPI自定义实现) + + 🔥🔥🔥轻量级动态线程池,内置监控告警功能,基于主流配置中心(已支持Nacos、Apollo、Zookeeper、Consul、Etcd、Polaris,可通过SPI自定义实现) + https://github.com/yanhom1314/dynamic-tp @@ -254,6 +256,21 @@ + + org.apache.maven.plugins + maven-jar-plugin + + + + ${project.artifactId} + ${project.version} + ${maven.build.timestamp} + yanhom + + + + + org.apache.maven.plugins maven-gpg-plugin diff --git a/test/test-common/src/test/java/org/dromara/dynamictp/test/common/em/JreEnumTest.java b/test/test-common/src/test/java/org/dromara/dynamictp/test/common/em/JreEnumTest.java index de5a49c27..0671e9b48 100644 --- a/test/test-common/src/test/java/org/dromara/dynamictp/test/common/em/JreEnumTest.java +++ b/test/test-common/src/test/java/org/dromara/dynamictp/test/common/em/JreEnumTest.java @@ -42,4 +42,16 @@ void testJRE11() { Assertions.assertEquals(JreEnum.JAVA_11, JreEnum.currentVersion()); } + @Test + @EnabledOnJre(value = JRE.JAVA_11) + void testJRE11GreaterThan() { + Assertions.assertTrue(JreEnum.greaterThan(JreEnum.JAVA_8)); + } + + @Test + @EnabledOnJre(value = JRE.JAVA_8) + void testJRE8LessThan() { + Assertions.assertTrue(JreEnum.lessThan(JreEnum.JAVA_11)); + } + }