Skip to content

Instantly share code, notes, and snippets.

@buzztaiki
Last active October 8, 2015 14:17
Show Gist options
  • Select an option

  • Save buzztaiki/3343590 to your computer and use it in GitHub Desktop.

Select an option

Save buzztaiki/3343590 to your computer and use it in GitHub Desktop.
lambda modoki at java.
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'
}
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;}})
);
}
}
@buzztaiki
Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment