Flow

Additional

Language
Java
Version
0.5 (Jul 29, 2017)
Created
Jul 14, 2017
Updated
Jul 29, 2017 (Retired)
Owner
Dharmesh Gohil (00ec454)
Contributor
Dharmesh Gohil (00ec454)
1
Activity
Badge
Generate
Download
Source code

Flow

The Very light weight java 8 like stream for Android.

Usage

Filter

        Flow.of(1, 2, 3, 4, 5, 6, 7, 8, 9)
                .filter(n -> n % 2 == 0)
                .forEach(System.out::println);

Reduce

        Integer sum = Flow.of(1, 2, 3, 4, 5, 6, 7, 8, 9)
                .reduce(0, (n1, n2) -> n1 + n2);
        System.out.println(sum);  //output: 45

First Match

        String firstMatch = Flow.of("USA", "Canada", "India", "Russia", "China")
                .firstMatch(c -> c.endsWith("ia"));
        System.out.println(firstMatch); //India

Map

        Flow.of("USA", "Canada", "India", "Russia", "China")
                .map(String::length).forEach(System.out::println);

How to include in your Android project

1. Add this to your project build.gradle

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

2. Add this to your app module's build.gradle file:

dependencies {
    ...
    compile 'com.github.00ec454:Flow:0.5'
}

check the of lib latest version

3. And start using .... :)