Last active
October 8, 2015 14:17
-
-
Save buzztaiki/3343590 to your computer and use it in GitHub Desktop.
lambda modoki at java.
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
| apply plugin: 'java' | |
| group = 'modoki' | |
| repositories { | |
| mavenCentral() | |
| mavenLocal() | |
| } | |
| dependencies { | |
| compile 'com.google.guava:guava:16.0.1' | |
| compile 'com.github.buzztaiki:jenova:1.0-SNAPSHOT' | |
| compile 'org.projectlombok:lombok:1.12.6' | |
| } | |
| compileJava.options.compilerArgs = [ | |
| '-processor', [ | |
| 'com.github.buzztaiki.jenova.AnnotationProcessor', | |
| 'lombok.core.AnnotationProcessor' | |
| ].join(',') | |
| ] | |
| task run(type: JavaExec) { | |
| classpath = sourceSets.main.runtimeClasspath | |
| main = 'Modoki' | |
| } |
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 com.github.buzztaiki.jenova.Jenova; | |
| import com.github.buzztaiki.jenova.Lambda; | |
| import com.google.common.base.Function; | |
| import com.google.common.base.Predicate; | |
| import com.google.common.collect.Iterables; | |
| import java.util.Arrays; | |
| import lombok.experimental.ExtensionMethod; | |
| @Jenova({ | |
| @Lambda(name="fn", type=Function.class), | |
| @Lambda(name="pred", type=Predicate.class) | |
| }) | |
| @ExtensionMethod(Iterables.class) | |
| public class Modoki { | |
| public static void main(String[] args) throws Exception { | |
| Iterable<Integer> l = Arrays.asList(1, 2, 3); | |
| System.out.println( | |
| l.filter(new pred<Integer>(){{return _1 > 1;}}) | |
| .transform(new fn<Integer, Integer>(){{return _1 * 2;}}) | |
| ); | |
| } | |
| } |
Author
buzztaiki
commented
Aug 13, 2012
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment