diff --git a/src/java-unions.js b/src/java-unions.js new file mode 100644 index 0000000..d7ef397 --- /dev/null +++ b/src/java-unions.js @@ -0,0 +1,25 @@ +const utils = require('./utils') +const javaType = require('./java-type') + + +module.exports = { + + mapUnions: (unions, models, namespace, suffix='models') => { + return unions.map(union => { + union.package = `${namespace}.${suffix}` + union.name = utils.pascalcase(union.name) + + union.types.forEach(type => { + models.forEach(model => { + if(type.name === model.name) { + model.implements = model.implements || [] + model.implements.push(union.name) + } + }) + }) + + return union + }) + } + +} \ No newline at end of file diff --git a/templates/axon-event.java.mustache b/templates/axon-event.java.mustache index d36e36c..b2b8b12 100644 --- a/templates/axon-event.java.mustache +++ b/templates/axon-event.java.mustache @@ -20,7 +20,7 @@ import lombok.*; @Data @NoArgsConstructor @AllArgsConstructor -public class {{name}} { +public class {{name}} {{#implements.length}}implements {{#implements}}.{{/implements}}{{/implement.length}} { @TargetAggregateIdentifier private {{{aggregateId.type.name}}} {{aggregateId.name}}; diff --git a/templates/lombok-model.java.mustache b/templates/lombok-model.java.mustache index 240dc65..63014f7 100644 --- a/templates/lombok-model.java.mustache +++ b/templates/lombok-model.java.mustache @@ -27,7 +27,7 @@ import {{{.}}}; **/ @Data @NoArgsConstructor -public class {{name}} { +public class {{name}} {{#implements.length}}implements {{#implements}}.{{/implements}}{{/implement.length}}{ {{#fields}} {{#description}}/** {{.}} **/{{/description}}