- A static function is basically a function from the arguments to the return value.
- A field is basically a function from the instance to the field value.
- A method is basically a function from the instance and the method arguments to the return value.
- A class constructor is basically a function from the arguments to an instance of that class.
We should be able to use these as if they were regular functions. Java8 finally made this possible, but not completely. This library makes them available also for java6 and java7. You can also use this with java8 if the "standard way" is not enough for you.
Put the following files (or the latest versions) to classpath and enable annotation processing in your build tool:
https://github.com/solita/functional-utils/releases/download/0.8/functional-utils-0.8.jar
https://github.com/solita/meta-utils/releases/download/0.8/meta-utils-0.8.jar
Add the jars to project dependencies:
Project properties -> Java Compiler -> Annotation Processing:
- Enable project specific settings
- Enable annotation processing
Project properties -> Java Compiler -> Annotation Processing -> Factory Path:
- Enable project specific settings
- Add JARs... and select functiona-utils jar
- Add JARs... and select meta-utils jar
Now whenever you save a file the metaclasses are automatically generated and immediately ready for use.
TODO: Anyone know how Idea supports Annotation Processors?
Please consult the documentation of your build tool on how to enable and control annotation processing.
Since I was able to generate the metaclasses for the standard Java library, there's a good chance that it will also work for whichever 3rd party library where the source code is available.
Meta-classes for the JDK as well as some 3rd party libraries are included in the release.
This package comes with no warranty what-so-ever. It's higly experimental, might contain loads of bugs and needs more testing. Packages and classes may get renamed or moved, and things may suddenly break. Use at your own risk!
And no, I honestly do not believe that Java is the language of the future. Please use a "real" language if you can. But if you are stuck in the enterprise world, this project might just make your life worth living.
Bug reports, feature requests and opinionated recommendations are highly welcome ;)
Copyright © Solita Oy
Distributed under the MIT License.