Java wrapper for the JHipster Domain Language JDL using Graalvm JS Truffle Language...
This is part of the ZenWave Code Generator project:
Configurable and extensible Code Generator for DDD and API-First modeling with support for JHipster JDL, AsyncAPI and OpenAPI
<dependency>
<groupId>io.github.zenwave360.jhipster</groupId>
<artifactId>jdl-jvm</artifactId>
<version>${jdl-jvm.version}</version>
</dependency>
String jdlString = Files.readString(Paths.get("jdl-samples-main/21-points.jh"));
Map<String, Object> parsedJDL = JDLParser.parseJDL(jdlString);
String jdlString = Files.readString(Paths.get("jdl-samples-main/21-points.jh"));
Map<String, Object> parsedJDL = JDLParser.parseJDL(jdlString, , Map.of("databaseType", "mongodb"));
Note: It uses Graalvm JS Truffle Language and performance is not that bad. It takes about 3' to load the js script and parse the jdl string.
Upstream JDL source code is located under src/main/jdl-core
folder.
You can bundle target/classes/io/zenwave360/jhipster/jdl/jdl-parser.js
using:
mvn generate-resources
from project root, ornpm run generate-resources
fromsrc/main/jdl-core
folder
This wrapper includes some extensions compatible with the original JDL format, meaning that valid JDL will produce the same jdlObject as the upstream jdl library.
- Field Types: in addition to enums and basic types it allows other entities (and arrays of) as field type, this is useful for embedded fields which are not relations.
- Service: in addition to
serviceClass
andserviceImpl
it allows configuring free text value asserviceName
to allow grouping multiple entities in a given service. Then it's up to each generator to generate an interface or just an implementation class.
- Adds annotation options to the entity object
- Adds
isEnum
,isEntity
andisArray
to entity fields - Adds
className
,instanceName
,classNamePlural
andinstanceNamePlural
to entity fields - Fill globaly configured options (like service, dto ,search...) to entity options for consistency