Import from http://hg.code.sf.net/p/streamsupport/code
streamsupport is a backport of the Java 8 java.util.function (functional interfaces) and java.util.stream (streams) API for users of Java 6 or 7 supplemented with selected additions from java.util.concurrent which didn't exist back in Java 6.
Due to the lack of default interface methods and static interface methods in pre-Java 8 the API had to be slightly adjusted in these areas but still covers the full functionality scope of Java 8. In detail, static and default interface methods have been moved to companion classes in the same package that bear the identical name as the interface but with an "s" appended (e.g. Comparator -> Comparators).
For ease of use, the default methods for most of the functional interfaces were NOT retained as abstract methods in the redefined interfaces (keeping them single method interfaces) - the missing default (and static) methods can always be found in the corresponding companion class.
Want also lambdas? https://github.com/orfjackal/retrolambda
Categories
Features
- Java 8 Streams library backport
- Java 8 CompletableFuture backport
- Java 8 Parallel array operations backport
- Java 8 Functional interfaces backport
- Further java.util.concurrent enhancements from Java 7/8 backported to Java 6
- Includes miscellaneous Java 8 goodies (Optional, StringJoiner, ...)
- Supports Android
Usage
After:
RefStreams.of("one", "two", "three", "four")
.filter(e -> e.length() > 3)
.peek(e -> System.out.println("Filtered value: " + e))
.map(String::toUpperCase)
.peek(e -> System.out.println("Mapped value: " + e))
.collect(Collectors.toList());
After:
public static List<String> getNames(List<User> users) {
return StreamSupport.stream(users).map(user -> user.name()).collect(Collectors.toList());
}
After:
public static String[] getNames(User[] users) {
return J8Arrays.stream(users).map(user -> user.name()).toArray(length -> new String[length]);
}
Installation
build.gradle:
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
compile 'net.sourceforge.streamsupport:streamsupport:1.5.6'
compile 'net.sourceforge.streamsupport:streamsupport-cfuture:1.5.6'
compile 'net.sourceforge.streamsupport:streamsupport-atomic:1.5.6'
compile 'net.sourceforge.streamsupport:streamsupport-flow:1.5.6'
compile 'net.sourceforge.streamsupport:streamsupport-literal:1.5.6'
//compile 'com.github.streamsupport.streamsupport:streamsupport-pro:-SNAPSHOT' // proguard config for android
}
or via jitpack:
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
compile 'com.github.streamsupport.streamsupport:streamsupport:-SNAPSHOT'
compile 'com.github.streamsupport.streamsupport:streamsupport-cfuture:-SNAPSHOT'
compile 'com.github.streamsupport.streamsupport:streamsupport-atomic:-SNAPSHOT'
compile 'com.github.streamsupport.streamsupport:streamsupport-flow:-SNAPSHOT'
compile 'com.github.streamsupport.streamsupport:streamsupport-literal:-SNAPSHOT'
//compile 'com.github.streamsupport.streamsupport:streamsupport-pro:-SNAPSHOT' // proguard config for android
}
Proguard
Build
maven
./mvnw clean install
gradle
./gradlew clean assemble
Importing
GIT_COMMITTER_NAME="" GIT_COMMITTER_EMAIL="" git rebase --committer-date-is-author-date 1.5.5 1.5.6 --onto _1.5.5
Release Notes
LICENSE
GPL2, CE (GNU General Public License, version 2, with the Classpath Exception)