This is an automated email from the ASF dual-hosted git repository.

pdallig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/master by this push:
     new e4f4cc88ed [ZEPPELIN-6243] Remove unused code in SemanticVersion class
e4f4cc88ed is described below

commit e4f4cc88ed7fbfb68d3b75e9285bbc63cb33e598
Author: eunhwa99 <[email protected]>
AuthorDate: Mon Jul 21 17:05:59 2025 +0900

    [ZEPPELIN-6243] Remove unused code in SemanticVersion class
    
    ### What is this PR for?
    This PR performs internal cleanup in the 
org.apache.zeppelin.test.SemanticVersion class by removing unused methods:
    These methods are not referenced anywhere in the Zeppelin codebase and 
serve no current functional purpose.
    ### What type of PR is it?
    Refactoring
    ### Todos
    * [x] - Remove unused methods in SemanticVersion
    
    ### What is the Jira issue?
    * [JIRA](https://issues.apache.org/jira/browse/ZEPPELIN-6243)
    
    ### How should this be tested?
    * No functional changes. No additional testing required.
    * CI should pass as usual.
    ### Screenshots (if appropriate)
    
    ### Questions:
    * Does the license files need to update? no
    * Is there breaking changes for older versions? no
    * Does this needs documentation? no
    
    
    Closes #4978 from eunhwa99/ZEPPELIN-6243.
    
    Signed-off-by: Philipp Dallig <[email protected]>
---
 .../org/apache/zeppelin/test/SemanticVersion.java  | 52 +++++++---------------
 1 file changed, 17 insertions(+), 35 deletions(-)

diff --git 
a/zeppelin-test/src/main/java/org/apache/zeppelin/test/SemanticVersion.java 
b/zeppelin-test/src/main/java/org/apache/zeppelin/test/SemanticVersion.java
index ceed1a872d..070b4d3ea3 100644
--- a/zeppelin-test/src/main/java/org/apache/zeppelin/test/SemanticVersion.java
+++ b/zeppelin-test/src/main/java/org/apache/zeppelin/test/SemanticVersion.java
@@ -23,7 +23,8 @@ import org.slf4j.LoggerFactory;
 /**
  * Provide reading comparing capability of semantic version which is used 
widely in Apache projects
  */
-public class SemanticVersion {
+public class SemanticVersion implements Comparable<SemanticVersion> {
+
   private static final Logger LOGGER = 
LoggerFactory.getLogger(SemanticVersion.class);
 
   public static SemanticVersion of(String versionString) {
@@ -31,14 +32,11 @@ public class SemanticVersion {
   }
 
   private final String versionString;
-  private int version;
-  private int majorVersion;
-  private int minorVersion;
-  private int patchVersion;
+  private final int version;
 
   private SemanticVersion(String versionString) {
     this.versionString = versionString;
-
+    int version;
     try {
       int pos = versionString.indexOf('-');
 
@@ -48,28 +46,19 @@ public class SemanticVersion {
       }
 
       String[] versions = numberPart.split("\\.");
-      this.majorVersion = Integer.parseInt(versions[0]);
-      this.minorVersion = Integer.parseInt(versions[1]);
-      this.patchVersion = Integer.parseInt(versions[2]);
+      int majorVersion = Integer.parseInt(versions[0]);
+      int minorVersion = Integer.parseInt(versions[1]);
+      int patchVersion = Integer.parseInt(versions[2]);
       // version is always 5 digits. (e.g. 2.0.0 -> 20000, 1.6.2 -> 10602)
-      version = Integer.parseInt(String.format("%d%02d%02d", majorVersion, 
minorVersion, patchVersion));
+      version = Integer.parseInt(
+          String.format("%d%02d%02d", majorVersion, minorVersion, 
patchVersion));
     } catch (Exception e) {
-      LOGGER.error("Can not recognize Spark version {}. Assume it's a future 
release", versionString, e);
+      LOGGER.error("Can not recognize Spark version {}. Assume it's a future 
release",
+          versionString, e);
       // assume it is future release
       version = 99999;
     }
-  }
-
-  public int getMajorVersion() {
-    return majorVersion;
-  }
-
-  public int getMinorVersion() {
-    return minorVersion;
-  }
-
-  public int getPatchVersion() {
-    return patchVersion;
+    this.version = version;
   }
 
   @Override
@@ -85,22 +74,15 @@ public class SemanticVersion {
   @Override
   public boolean equals(Object versionToCompare) {
     return versionToCompare instanceof SemanticVersion
-            && version == ((SemanticVersion) versionToCompare).version;
+        && this.compareTo((SemanticVersion) versionToCompare) == 0;
   }
 
-  public boolean newerThan(SemanticVersion versionToCompare) {
-    return version > versionToCompare.version;
+  @Override
+  public int compareTo(SemanticVersion other) {
+    return Integer.compare(this.version, other.version);
   }
 
   public boolean equalsOrNewerThan(SemanticVersion versionToCompare) {
-    return version >= versionToCompare.version;
-  }
-
-  public boolean olderThan(SemanticVersion versionToCompare) {
-    return version < versionToCompare.version;
-  }
-
-  public boolean equalsOrOlderThan(SemanticVersion versionToCompare) {
-    return version <= versionToCompare.version;
+    return this.compareTo(versionToCompare) >= 0;
   }
 }

Reply via email to