Giter Club home page Giter Club logo

android-retrostreams's Introduction

Maven Central javadoc.io

android-retrostreams

android-retrostreams is a fork of the streamsupport library targeted at Android developers who want to take advantage of Android Studio 3.x D8 / desugar toolchain's capability to use interface default & static methods across Jar file boundaries.

Utilizing this feature of desugar, the streamsupport API can be even more aligned with the original Java 8 / 9 API exposed in the java.util.function and java.util.stream packages. That allows for Android app's code to be much more in accordance with the standard Java 8 / 9 usage than it is now possible with the original streamsupport API (which is bound by the restrictions of supporting Java 6).

With respect to static / default interface methods the android-retrostreams public API should now be identical to the Java 9 API wherever this is possible (i.e. for all interfaces that have first been introduced in Java 8).

Supplemental helper classes, public static methods and so on that served as a replacement for the default / static interfaces methods in the original streamsupport API are now mostly gone. E.g., no j8.u.s.RefStreams class anymore - all these methods are now in the j9.u.s.Stream interface.

The retrostreams API lives in the packages java9.util.* and java9.lang respectively. So, it's not possible to simply import the java.util.stream package in your code - you'd rather have to use java9.util.stream instead. While that is fine as long as you have full control over your source code there is the other common scenario of using a binary 3rd party dependency that has been compiled against the standard Java 8 java.util.stream API. In the latter case bytecode rewriting via ProGuard might be an option. ProGuard supports most Java 8 language features and the latest release can also replace the standard Java 8 stream API by the streamsupport backport (cf. the Proguard documentation, especially the section titled "Java 8 stream API support"), i.e., in this case, switching to the older streamsupport backport instead of using android-retrostreams might be the more promising approach.

The online Javadoc gives a picture of the API changes.

The current stable release of retrostreams is android-retrostreams-1.7.4.

Please give feedback here if you experience any problems.

build.gradle:

dependencies {
    implementation 'net.sourceforge.streamsupport:android-retrostreams:1.7.4'
}

All-in-One JAR:

Contains android-retrostreams core + retroatomic + retroflow + retrofuture

dependencies {
    implementation 'net.sourceforge.streamsupport:android-retrostreams_all:1.7.4'
}

Example usage

import java.util.List;
import java9.util.stream.Stream;
import java9.util.stream.StreamSupport;
import static java9.util.stream.Collectors.toList;

List<Integer> list = Stream.of(1, 2, 3, 4).collect(toList());

List<Integer> incremented = StreamSupport.stream(list)
        .map(i -> i + 1)
        .collect(toList());

Sibling projects

You might also have a use for one of retrostreams' sibling projects:

LICENSE

GNU General Public License, version 2, with the Classpath Exception (and CC0 1.0 for JSR-166 derived code)

android-retrostreams's People

Contributors

dexpota avatar retrostreams avatar stefan-zobel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-retrostreams's Issues

Include more complete usage guide in Readme

The usage of this project (and Android's desugar/d8 toolchain) is a little light.

How would I configure D8 to use this library. I'm guessing I need to configure byte code translation to rewrite package names, but i'm not sure where that is configured.

Are there example projects?

v1.7.3 error with proguard

Hello,

just update to 1.7.3, no problem in debug mode. But in release, i can't collect.

StreamSupport.stream(list).sorted(comparator).collect(Collectors.toCollection(supplier));

Problem arise when i collect (stream and sorted are ok).

Collect give me this error:

java.lang.NoSuchMethodException: listFromTrustedArray [class [Ljava.lang.Object;]

I switched back to version 1.7.2, problem disappear. That's obviously some missing protection from proguard but what ?

Call for feedback (either positive or negative)

The current beta-1 version obviously needs more testing by different users.

I'd really appreciate if you would share your experience with me here.
Do you encounter any problems? Or not?

How does it feel to program with AS 3 against the new API? Is it really that much better (compared to streamsupport) that a separate fork is justifiable?

Please share your thoughts with me. If you encounter any bugs, I would very much welcome if you create an issue here. I'll look into any issue as soon as my work schedule permits.

Thanks in advance,
Stefan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.