Fix using Java 8 methods

This commit is contained in:
huangyuhui 2018-08-15 03:18:09 +08:00
parent c47dea94e3
commit bd38c9424f
4 changed files with 10 additions and 14 deletions

View File

@ -38,11 +38,11 @@ def buildnumber = System.getenv("TRAVIS_BUILD_NUMBER")
if (buildnumber == null)
buildnumber = System.getenv("BUILD_NUMBER")
if (buildnumber == null)
buildnumber = "52"
buildnumber = "60"
def versionroot = System.getenv("VERSION_ROOT")
if (versionroot == null)
versionroot = "2.7.9"
versionroot = "2.7.10"
String mavenGroupId = 'HMCL'
String mavenVersion = versionroot + '.' + buildnumber

View File

@ -18,6 +18,7 @@
package org.jackhuang.hmcl.api;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@ -38,9 +39,9 @@ public final class ComposedVersionNumber extends VersionNumber {
}
ComposedVersionNumber(String version) {
composed = Arrays.stream(version.split("-"))
.map(VersionNumber::asVersion)
.collect(Collectors.toList());
String slice[] = version.split("-");
composed = new LinkedList<>();
for (String str : slice) composed.add(VersionNumber.asVersion(str));
}
@Override
@ -50,6 +51,9 @@ public final class ComposedVersionNumber extends VersionNumber {
@Override
public String toString() {
return composed.stream().map(VersionNumber::toString).collect(Collectors.joining("-"));
List<String> seq = new LinkedList<>();
for (VersionNumber str : composed)
seq.add(str.toString());
return String.join("-", seq);
}
}

View File

@ -20,7 +20,6 @@ package org.jackhuang.hmcl.api;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* If a version string formats x.x.x.x, a {@code IntVersionNumber}

View File

@ -36,13 +36,6 @@ public abstract class VersionNumber implements Comparable<VersionNumber> {
return new StringVersionNumber(version);
}
public static Optional<String> parseVersion(String str) {
if (IntVersionNumber.isIntVersionNumber(str))
return Optional.of(new IntVersionNumber(str).toString());
else
return Optional.empty();
}
@Override
public int compareTo(VersionNumber o) {
return COMPARATOR.compare(this, o);