-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
96 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/org/cryptomator/frontend/fuse/VersionCompare.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.cryptomator.frontend.fuse; | ||
|
||
/** | ||
* from: https://www.baeldung.com/java-comparing-versions#customSolution | ||
*/ | ||
public class VersionCompare { | ||
|
||
public static int compareVersions(String version1, String version2) { | ||
int comparisonResult = 0; | ||
|
||
String[] version1Splits = version1.split("\\."); | ||
String[] version2Splits = version2.split("\\."); | ||
int maxLengthOfVersionSplits = Math.max(version1Splits.length, version2Splits.length); | ||
|
||
for (int i = 0; i < maxLengthOfVersionSplits; i++){ | ||
Integer v1 = i < version1Splits.length ? Integer.parseInt(version1Splits[i]) : 0; | ||
Integer v2 = i < version2Splits.length ? Integer.parseInt(version2Splits[i]) : 0; | ||
int compare = v1.compareTo(v2); | ||
if (compare != 0) { | ||
comparisonResult = compare; | ||
break; | ||
} | ||
} | ||
return comparisonResult; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters