VMF is a lightweight modeling framework. It conveniently translates annotated Java interfaces into powerful implementations. It writes all the inevitable but boring boilerplate code for you and provides a modern and stable API. It is designed to work with the newest versions of Java as soon as they are released. It works well with Java 11-24. It generates/supports:
- getters and setters
- default values
- containment
- builder API
- equals() and hashCode()
- deep and shallow cloning
- change notification and observer scopes
- undo/redo
- portable change journals in JSON, YAML, and XML (feature preview)
- object graph traversal API via iterators and streams
- immutable types and read-only wrappers
- delegation
- annotations and unified
vmf:*reflection metadata - stable reference IDs (
@Id), wire names (@WireName), and zero-boilerplate journal bindings - collection properties, UML multiplicity, and keyed relationships
- managed map properties
- generic model interfaces and inherited relationships
- Jackson serialization for existing JSON and reference-aware JSON, YAML, and XML
- model validation and custom rules
- JSON Schema generation for validation and visual editors
- ...
A VMF model consists of annotated Java interfaces. We could call this "wannabe" code. Just specify the interface and its properties and get a fully functional implementation including property setters and getters, builders, iterators, and much more. Even for a simple model VMF provides a lot of useful APIs:
VMF models are declared once as annotated Java interfaces and can generate native code for Java, C# (.NET 10), TypeScript (ES2022), and Python (3.10+). VMF separates core modeling behavior from serialization and platform-specific integrations:
| Category | Multilingual (Portable Contract: Java, C#, TypeScript, Python) | Java + C# (Target-specific extras) | Single-language / Platform-specific |
|---|---|---|---|
| Core modeling | Types, multiple inheritance, @InterfaceOnly, redeclaration, generics, scalars & defaults, containment & cycles, opposite references, content equality & deep copy, read-only views & @Immutable, sets/ordered sets/maps/keyed containment, @DelegateTo behaviors & hooks, external types/enums/UUID/untyped Object, reflection order & annotations, declared validation (@Multiplicity, @Range, @Length, @Pattern), depth-first graph traversal & writable cursors (traversal) |
Builders (applyFrom/applyTo), static type catalog & reflection writes, ModelValidator application rules & reference-following, shallow copy*, list sort / removeIf* |
Java: generator host (Gradle/Maven plugins, IntelliJ integration, vmfedit), VCollections interop.C#: IEquatable<T>, object initializers, partial binding methods.TypeScript: vmf.edit(...) rollback blocks, installModelBindings(...), bigint for 64-bit long, identity-only === (N3) with contentEquals().Python: PEP 8 snake_case, PEP 484/561 typing, with vmf.edit(origin): rollback blocks, install_model_bindings(...), native __eq__/__hash__ (N2). |
| Events & history | Local & recursive listeners, registration order (E7), nearest-ancestor delivery (E8), immediate reentrant listener edits (E9), recording & undo/redo with causal recording order (H4) |
Direct property & raw collection listeners, native transactions | Java: JavaBeans PropertyChangeListener.C#: INotifyPropertyChanged (WPF/MAUI/Avalonia binding) on mutable models & read-only views. |
| Serialization & interchange | JSON (json module): reference-aware snapshots (stable @Id references J7 or synthetic @vmf-id, plus @vmf-type and @WireName) and plain external JSON (ReferenceMode: IDS / REJECT / OMIT) |
XML & YAML snapshots (via Jackson in Java), per-format @WireName(format = ...) overrides, Draft-07 JSON Schema generation, feature bundles (plugin persistence), V1 preview change journals (JournalBinding.forModel / CreateJournalBinding) / diff / merge / patches** |
Java: arbitrary Jackson-serializable untyped Object payloads; direct ChangeJournal JSON/YAML/XML via VMFJacksonModule; custom formats via VMFJacksonModule.withFormat(...). |
* Shallow copy and list sort/removeIf are kept Java+C# for now and recorded as candidates for future contract extension.
** Portable change journals remain a feature preview (envelope v1) and will be evaluated for a portable contract module once the format leaves preview.
- Contract & scenarios: The portable contract defines all 87 shared rules across 13 modules;
./gradlew :vmf:verifyPortableContractexecutes the shared JSON scenarios on Java, C#, TypeScript, and Python. - Language mappings: Java, C#, TypeScript, and Python.
- Workshop & C# conformance: The Workshop example exchanges reference-aware and plain JSON across all four targets; conformance/TEST-AREAS.md records the classification of every C# conformance area.
Checkout the tutorial projects: https://github.com/miho/VMF-Tutorials
For Maven projects, see the VMF Maven plugin guide.
VMF comes with excellent Gradle support. Just add the plugin like so (get the latest version here):
plugins {
id "eu.mihosoft.vmf" version "0.4.0"
}Now just add the model definitions to the VMF source folder, e.g., src/main/vmf/. 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")
Child[] getChildren();
String getName();
}
interface Child {
@Container(opposite="children")
Parent getParent();
int getValue();
}Just call the vmfGenModelSources task to generate the implementation.
See Generic model interfaces for reusable property declarations with named concrete bindings.
To improve IDE support, enable the IntelliJ support via
buildscript {
ext.vmfPluginIntelliJIntegration = true
}
Register the core and plugin models in a ModelRegistry. Once the plugins have
attached their VMF objects, use the codec from vmf-jackson to save and reload
the owner and its directly attached features in one file. Use a .json, .yaml,
.yml, or .xml filename, or pass the shared VMFDocumentFormat explicitly.
A filename without an extension uses JSON. Unrecognized extensions require an explicit format.
var codec = new VMFFeatureCodec(registry);
codec.save(path, device, attachments);
var loaded = codec.load(path, Device.class);
Device restored = loaded.owner();
var calibration = loaded.attachments().find(restored, Calibration.class);The codec handles modeled properties for each registered feature type. If a plugin required by the file is missing, loading reports its type name. See the two-plugin example.
Between releases, main is published as -SNAPSHOT (e.g. 0.5.0-SNAPSHOT) to the Maven Central snapshot repository. To use it, add the repository for plugins (settings.gradle) and, for other VMF artifacts such as vmf-jackson, for dependencies:
// settings.gradle
pluginManagement {
repositories {
maven {
url = uri('https://central.sonatype.com/repository/maven-snapshots/')
mavenContent { snapshotsOnly() }
}
gradlePluginPortal()
mavenCentral()
}
}// build.gradle
plugins {
id "eu.mihosoft.vmf" version "0.5.0-SNAPSHOT"
}
repositories {
mavenCentral()
maven {
url = uri('https://central.sonatype.com/repository/maven-snapshots/')
mavenContent { snapshotsOnly() }
}
}Snapshots change without notice and are deleted after 90 days; Gradle caches them for 24 hours (--refresh-dependencies fetches the latest). How snapshots and releases are published: docs/RELEASING.md.
- Install JDK 11 and JDK 17. Set
JAVA_HOMEto the JDK that runs Gradle. CI uses JDK 17, 21 and 24. - Install Maven (
mvnon your path) to run the full build. - The first build downloads dependencies.
- IDE: Gradle Plugin (not necessary for command line usage)
Open the VMF Gradle project in your favourite IDE (tested with IntelliJ 2024) and build it
by executing the publishToMavenLocal task.
Navigate to the VMFGradle project (i.e., path/to/VMF/) and enter the following command
bash gradlew publishToMavenLocal
gradlew publishToMavenLocal
NOTE: to execute the tests within the VMF project (basic tests) execute the
testtask after executingpublishToMavenLocal.
From the repository root, run sh ./build-and-test-all.sh on Linux or macOS, or
build-and-test-all.bat on Windows. These are the same commands that CI uses.
They build VMF into your local Maven repository and test the generator, both
build plugins, generated models and Jackson integration.
Once dependencies are cached, append --offline to either command. This lets
you run the full suite during a repository outage without requesting dependencies
or publishing artifacts to Maven Central.
An HTML version of the test report is located in the build folder test-suite/build/reports/tests/test/index.html.
Run the local performance gate to check containment, events, recording, and replay against a saved machine-local baseline.