-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Replace Groovy `.collect` calls with `Transform.toList`.
- Loading branch information
Showing
11 changed files
with
72 additions
and
37 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
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
34 changes: 34 additions & 0 deletions
34
core-plugin/src/main/groovy/com/github/jrubygradle/internal/core/Transform.groovy
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,34 @@ | ||
package com.github.jrubygradle.internal.core | ||
|
||
import groovy.transform.CompileStatic | ||
|
||
import java.util.function.Function | ||
import java.util.stream.Collectors | ||
|
||
/** Transforms a collection to another collection. | ||
* | ||
* Deals with Groovy 2.4/2.5 backwards incompatibility. | ||
* | ||
* @author Schalk W. Cronjé | ||
* | ||
* @since 2.0 | ||
* | ||
*/ | ||
@CompileStatic | ||
class Transform { | ||
static <I,O> List<O> toList(final Collection<I> collection, Function<I,O> tx ) { | ||
collection.stream().map(tx).collect(Collectors.toList()) | ||
} | ||
|
||
static <I,O> List<O> toList(final I[] collection, Function<I,O> tx ) { | ||
collection.toList().stream().map(tx).collect(Collectors.toList()) | ||
} | ||
|
||
static <I,O> Set<O> toSet(final Collection<I> collection, Function<I,O> tx ) { | ||
collection.stream().map(tx).collect(Collectors.toSet()) | ||
} | ||
|
||
static <I,O> Set<O> toSet(final Iterable<I> collection, Function<I,O> tx ) { | ||
collection.toList().stream().map(tx).collect(Collectors.toSet()) | ||
} | ||
} |
Binary file not shown.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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