VMF is a lightweight modeling framework. It conveniently translates annotated Java interfaces into powerful implementations.
It generates/supports:
- getters and setters
- default values
- containment
- builder API
- equals() and hashCode()
- deep and shallow cloning
- change notification
- undo/redo
- object graph traversal API via iterators and streams
- immutable types and read-only wrappers
- delegation
A VMF model consists of annotated Java interfaces. We could call this "wannabe" code. We just specify the interface and its properties and get a rich implementation that implements the property setters and getters, builders and much more. Even for a simple model VMF generated a lot of useful API:
Checkout the tutorial projects: https://github.com/miho/VMF-Tutorials
VMF comes with excellent Gradle support. Just add the plugin like so:
plugins {
id "eu.mihosoft.vmf" version "0.1.1" // use latest version
}
and configure VMF:
vmf {
version = '0.1' // use desired VMF version
}
Now just add the model definitions to the VMF source folder, e.g., src/vmf/java
. The package name must end with .vmfmodel
, for example:
package eu.mihosoft.vmf.tutorial.vmfmodel;
import eu.mihosoft.vmf.core.Container;
import eu.mihosoft.vmf.core.Contains;
interface Parent {
@Contains(opposite = "parent")
MyChild[] getChildren();
String getName();
}
interface Child {
@Container(opposite="children")
MyParent getParent();
int getValue();
}
Just call the vmfGenModelSources
task to generate the implementation.
- Java >= 1.8
- Internet connection (dependencies are downloaded automatically)
- IDE: Gradle Plugin (not necessary for command line usage)
Open the VMF
Gradle project in your favourite IDE (tested with NetBeans 8.2 and IntelliJ 2018) and build it
by calling the publishToMavenLocal
task.
Navigate to the Gradle project (e.g., path/to/VMF
) and enter the following command
bash gradlew publishToMavenLocal
gradlew publishToMavenLocal
Use the test suite TODO