Skip to content

Commit e4f4cc8

Browse files
authored
[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]>
1 parent 9cf4121 commit e4f4cc8

1 file changed

Lines changed: 17 additions & 35 deletions

File tree

zeppelin-test/src/main/java/org/apache/zeppelin/test/SemanticVersion.java

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,20 @@
2323
/**
2424
* Provide reading comparing capability of semantic version which is used widely in Apache projects
2525
*/
26-
public class SemanticVersion {
26+
public class SemanticVersion implements Comparable<SemanticVersion> {
27+
2728
private static final Logger LOGGER = LoggerFactory.getLogger(SemanticVersion.class);
2829

2930
public static SemanticVersion of(String versionString) {
3031
return new SemanticVersion(versionString);
3132
}
3233

3334
private final String versionString;
34-
private int version;
35-
private int majorVersion;
36-
private int minorVersion;
37-
private int patchVersion;
35+
private final int version;
3836

3937
private SemanticVersion(String versionString) {
4038
this.versionString = versionString;
41-
39+
int version;
4240
try {
4341
int pos = versionString.indexOf('-');
4442

@@ -48,28 +46,19 @@ private SemanticVersion(String versionString) {
4846
}
4947

5048
String[] versions = numberPart.split("\\.");
51-
this.majorVersion = Integer.parseInt(versions[0]);
52-
this.minorVersion = Integer.parseInt(versions[1]);
53-
this.patchVersion = Integer.parseInt(versions[2]);
49+
int majorVersion = Integer.parseInt(versions[0]);
50+
int minorVersion = Integer.parseInt(versions[1]);
51+
int patchVersion = Integer.parseInt(versions[2]);
5452
// version is always 5 digits. (e.g. 2.0.0 -> 20000, 1.6.2 -> 10602)
55-
version = Integer.parseInt(String.format("%d%02d%02d", majorVersion, minorVersion, patchVersion));
53+
version = Integer.parseInt(
54+
String.format("%d%02d%02d", majorVersion, minorVersion, patchVersion));
5655
} catch (Exception e) {
57-
LOGGER.error("Can not recognize Spark version {}. Assume it's a future release", versionString, e);
56+
LOGGER.error("Can not recognize Spark version {}. Assume it's a future release",
57+
versionString, e);
5858
// assume it is future release
5959
version = 99999;
6060
}
61-
}
62-
63-
public int getMajorVersion() {
64-
return majorVersion;
65-
}
66-
67-
public int getMinorVersion() {
68-
return minorVersion;
69-
}
70-
71-
public int getPatchVersion() {
72-
return patchVersion;
61+
this.version = version;
7362
}
7463

7564
@Override
@@ -85,22 +74,15 @@ public int hashCode() {
8574
@Override
8675
public boolean equals(Object versionToCompare) {
8776
return versionToCompare instanceof SemanticVersion
88-
&& version == ((SemanticVersion) versionToCompare).version;
77+
&& this.compareTo((SemanticVersion) versionToCompare) == 0;
8978
}
9079

91-
public boolean newerThan(SemanticVersion versionToCompare) {
92-
return version > versionToCompare.version;
80+
@Override
81+
public int compareTo(SemanticVersion other) {
82+
return Integer.compare(this.version, other.version);
9383
}
9484

9585
public boolean equalsOrNewerThan(SemanticVersion versionToCompare) {
96-
return version >= versionToCompare.version;
97-
}
98-
99-
public boolean olderThan(SemanticVersion versionToCompare) {
100-
return version < versionToCompare.version;
101-
}
102-
103-
public boolean equalsOrOlderThan(SemanticVersion versionToCompare) {
104-
return version <= versionToCompare.version;
86+
return this.compareTo(versionToCompare) >= 0;
10587
}
10688
}

0 commit comments

Comments
 (0)