danstutzman/BlockSyntaxInJava
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Currently, functional programing in Java often requires creating anonymous classes. For example: List<Integer> ints = Arrays.asList(new Integer[] { 1, 2, 3 }); List<Integer> negativeInts = map(ints, new IntTransformer() { public int transform(int _) { return -_; } }); The BlockSyntaxInJava offers some C-preprocessor macros to reduce the amount of code that's needed: List<Integer> ints = Arrays.asList(new Integer[] { 1, 2, 3 }); List<Integer> negativeInts = MAP_LO_LO(ints, Integer, Integer, { return -_; }); The name of the macro MAP_LO_LO can be read as: 1. "Map..." 2. "...from a List of objects..." 3. "...to a List of objects." The macro MAP_OC_OC takes four parameters: 1. the List of objects to read as input 2. the class of the input objects 3. the class of the output objects 4. the contents of the anonymous closure, ending with a return statement.
About
C macros to make Java anonymous classes less verbose
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published