-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move code to split up a list of versions into series
- Loading branch information
1 parent
14fcf4b
commit c50aa32
Showing
4 changed files
with
123 additions
and
42 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
48 changes: 48 additions & 0 deletions
48
src/integrationTest/java/eu/xenit/gradle/testrunner/versions/GradleVersionSeries.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,48 @@ | ||
package eu.xenit.gradle.testrunner.versions; | ||
|
||
import java.util.Collection; | ||
import java.util.Set; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Collectors; | ||
|
||
public class GradleVersionSeries { | ||
private final String series; | ||
private final Set<GradleVersionSpec> versionSpecs; | ||
|
||
public GradleVersionSeries(String series, Set<GradleVersionSpec> versionSpecs) { | ||
this.series = series; | ||
this.versionSpecs = versionSpecs; | ||
} | ||
|
||
public static GradleVersionSeries extract(String series, Collection<GradleVersionSpec> versionSpecs) { | ||
Set<GradleVersionSpec> extractedVersions = versionSpecs.stream() | ||
.filter(spec -> spec.getVersionSeries().contains(series)) | ||
.collect(Collectors.toSet()); | ||
return new GradleVersionSeries(series, extractedVersions); | ||
} | ||
|
||
public int getSeriesPriority() { | ||
return series.split("\\.").length; | ||
} | ||
|
||
public GradleVersionSpec getLowestVersion() { | ||
return versionSpecs.stream() | ||
.min(GradleVersionSpec.BY_VERSION_NUMBER) | ||
.orElse(null); | ||
} | ||
|
||
public GradleVersionSpec getHighestVersion() { | ||
return versionSpecs.stream() | ||
.max(GradleVersionSpec.BY_VERSION_NUMBER) | ||
.orElse(null); | ||
} | ||
|
||
public GradleVersionSeries filter(Predicate<GradleVersionSpec> predicate) { | ||
return new GradleVersionSeries(series, versionSpecs.stream().filter(predicate).collect(Collectors.toSet())); | ||
} | ||
|
||
public boolean isEmpty() { | ||
return versionSpecs.isEmpty(); | ||
} | ||
|
||
} |
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