Last active
December 19, 2016 14:35
-
-
Save sliskiCode/170867dab3a9ee8da85801dd84c0a065 to your computer and use it in GitHub Desktop.
Living (Android) without Kotlin #11
This file contains hidden or 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
| import lombok.Data; | |
| import lombok.experimental.ExtensionMethod; | |
| @ExtensionMethod(Streams.class) | |
| public class Foo { | |
| void foo(List<Person> persons) { | |
| persons.toStream() | |
| .filter(it -> it.getAge() >= 21) | |
| .filter(it -> it.getName().startsWith("P")) | |
| .map(Person::getName) | |
| .sorted() | |
| .forEach(System.out::println); | |
| } | |
| } | |
| @Data class Person { | |
| final String name; | |
| final int age; | |
| } | |
| class Streams { | |
| static <T> Stream<T> toStream(List<T> list) { | |
| return Stream.of(list); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment