From 03513b049c6f358c93a06957310466cd93712707 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Thu, 16 Jul 2020 15:58:10 +0200 Subject: [PATCH 01/28] Use separate lexer channel for JavaDoc comments --- src/main/antlr/FulibClass.g4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/antlr/FulibClass.g4 b/src/main/antlr/FulibClass.g4 index bfff8237..7ccd93be 100644 --- a/src/main/antlr/FulibClass.g4 +++ b/src/main/antlr/FulibClass.g4 @@ -147,7 +147,7 @@ DOUBLE: 'double'; THIS: 'this'; NEW: 'new'; -DOC_COMMENT: '/**' .*? '*/' -> channel(2); +DOC_COMMENT: '/**' .*? '*/' -> channel(3); // TODO named JAVADOC channel (requires separate lexer + parser grammars) BLOCK_COMMENT: '/*' .*? '*/' -> channel(2); LINE_COMMENT: '//' .*? '\n' -> channel(2); From 1d106ce780a482f5a9e3590c90c3e3ab152f25c6 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Thu, 16 Jul 2020 15:58:30 +0200 Subject: [PATCH 02/28] Save tokenStream in FragmentMapBuilder --- src/main/java/org/fulib/parser/FragmentMapBuilder.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/fulib/parser/FragmentMapBuilder.java b/src/main/java/org/fulib/parser/FragmentMapBuilder.java index 99fa164f..00772cf6 100644 --- a/src/main/java/org/fulib/parser/FragmentMapBuilder.java +++ b/src/main/java/org/fulib/parser/FragmentMapBuilder.java @@ -27,6 +27,7 @@ public class FragmentMapBuilder extends FulibClassBaseListener // =============== Fields =============== private final CharStream input; + private final CommonTokenStream tokenStream; private final FileFragmentMap map; private int lastFragmentEndPos = -1; @@ -34,9 +35,10 @@ public class FragmentMapBuilder extends FulibClassBaseListener // =============== Constructors =============== - public FragmentMapBuilder(CharStream input, FileFragmentMap map) + public FragmentMapBuilder(CharStream input, CommonTokenStream tokenStream, FileFragmentMap map) { this.input = input; + this.tokenStream = tokenStream; this.map = map; } @@ -60,7 +62,8 @@ public static FileFragmentMap parse(String fileName) public static FileFragmentMap parse(String fileName, CharStream input) { final FulibClassLexer lexer = new FulibClassLexer(input); - final FulibClassParser parser = new FulibClassParser(new CommonTokenStream(lexer)); + final CommonTokenStream tokenStream = new CommonTokenStream(lexer); + final FulibClassParser parser = new FulibClassParser(tokenStream); parser.removeErrorListeners(); final StringWriter writer = new StringWriter(); @@ -69,7 +72,7 @@ public static FileFragmentMap parse(String fileName, CharStream input) final FileContext context = parser.file(); final FileFragmentMap map = new FileFragmentMap(fileName); - final FragmentMapBuilder builder = new FragmentMapBuilder(input, map); + final FragmentMapBuilder builder = new FragmentMapBuilder(input, tokenStream, map); ParseTreeWalker.DEFAULT.walk(builder, context); final String errors = writer.toString(); From 8712cc58e1a20e500130b71e38354dd26c5bc6ac Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Fri, 17 Jul 2020 19:15:08 +0200 Subject: [PATCH 03/28] Include JavaDoc comments in Method and Constructor fragments --- .../org/fulib/parser/FragmentMapBuilder.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/fulib/parser/FragmentMapBuilder.java b/src/main/java/org/fulib/parser/FragmentMapBuilder.java index 00772cf6..b1956f60 100644 --- a/src/main/java/org/fulib/parser/FragmentMapBuilder.java +++ b/src/main/java/org/fulib/parser/FragmentMapBuilder.java @@ -219,7 +219,8 @@ public void enterConstructorMember(ConstructorMemberContext ctx) signature.append(this.className); writeParams(signature, ctx.parameterList()); - this.addCodeFragment(signature.toString(), memberCtx); + final Token start = this.getStartOrJavaDoc(memberCtx); + this.addCodeFragment(signature.toString(), start, memberCtx.getStop()); } @Override @@ -239,7 +240,29 @@ public void enterMethodMember(MethodMemberContext ctx) signature.append(methodName); writeParams(signature, ctx.parameterList()); - this.addCodeFragment(signature.toString(), memberCtx); + final Token start = this.getStartOrJavaDoc(memberCtx); + this.addCodeFragment(signature.toString(), start, memberCtx.getStop()); + } + + private Token getStartOrJavaDoc(MemberContext memberCtx) + { + final Token start = memberCtx.getStart(); + for (int i = start.getTokenIndex() - 1; i >= 0; i--) + { + final Token prev = this.tokenStream.get(i); + switch (prev.getChannel()) + { + case 2: // TODO FulibClassLexer.COMMENT + // regular comments between the JavaDoc comment and the declaration are ok + continue; + case 3: // TODO FulibClassLexer.JAVADOC + return prev; + default: + // anything other than a comment indicates that there is no JavaDoc comment for this declaration + return start; + } + } + return start; } private static void writeParams(StringBuilder signature, ParameterListContext paramsCtx) From 5d19fbd82fbccb2b6b30b19c2f2ceef0a7dbbd35 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Fri, 17 Jul 2020 19:18:46 +0200 Subject: [PATCH 04/28] Include JavaDoc comments in Class Declaration fragments --- src/main/java/org/fulib/parser/FragmentMapBuilder.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/fulib/parser/FragmentMapBuilder.java b/src/main/java/org/fulib/parser/FragmentMapBuilder.java index b1956f60..622e384b 100644 --- a/src/main/java/org/fulib/parser/FragmentMapBuilder.java +++ b/src/main/java/org/fulib/parser/FragmentMapBuilder.java @@ -155,8 +155,10 @@ public void enterClassDecl(ClassDeclContext ctx) { final ClassMemberContext classMemberCtx = ctx.classMember(); this.className = classMemberCtx.IDENTIFIER().getText(); - this.addCodeFragment(CLASS + '/' + this.className + '/' + CLASS_DECL, ctx.getStart().getStartIndex(), - classMemberCtx.classBody().LBRACE().getSymbol().getStopIndex()); + + final Token start = this.getStartOrJavaDoc(ctx); + final Token stop = classMemberCtx.classBody().LBRACE().getSymbol(); + this.addCodeFragment(CLASS + '/' + this.className + '/' + CLASS_DECL, start, stop); } @Override @@ -244,7 +246,7 @@ public void enterMethodMember(MethodMemberContext ctx) this.addCodeFragment(signature.toString(), start, memberCtx.getStop()); } - private Token getStartOrJavaDoc(MemberContext memberCtx) + private Token getStartOrJavaDoc(ParserRuleContext memberCtx) { final Token start = memberCtx.getStart(); for (int i = start.getTokenIndex() - 1; i >= 0; i--) From 19ead06d660944c9e6fe97b991fadcac514d797e Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Fri, 17 Jul 2020 19:23:48 +0200 Subject: [PATCH 05/28] Include JavaDoc comments in Field fragments --- .../java/org/fulib/parser/FragmentMapBuilder.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/fulib/parser/FragmentMapBuilder.java b/src/main/java/org/fulib/parser/FragmentMapBuilder.java index 622e384b..d0d07a34 100644 --- a/src/main/java/org/fulib/parser/FragmentMapBuilder.java +++ b/src/main/java/org/fulib/parser/FragmentMapBuilder.java @@ -172,7 +172,9 @@ public void enterFieldMember(FieldMemberContext ctx) if (size == 1) { // only one field, straightforward (pass the whole ctx) - this.addCodeFragment(CLASS + '/' + this.className + '/' + ATTRIBUTE + '/' + firstName, memberCtx); + final Token start = this.getStartOrJavaDoc(memberCtx); + final Token stop = memberCtx.getStop(); + this.addCodeFragment(CLASS + '/' + this.className + '/' + ATTRIBUTE + '/' + firstName, start, stop); return; } @@ -189,21 +191,21 @@ public void enterFieldMember(FieldMemberContext ctx) final List commas = ctx.COMMA(); // first part includes type and annotations and first comma - this.addCodeFragment(CLASS + '/' + this.className + '/' + ATTRIBUTE + '/' + firstName, memberCtx.getStart(), - commas.get(0).getSymbol()); + this.addCodeFragment(CLASS + '/' + this.className + '/' + ATTRIBUTE + '/' + firstName, + this.getStartOrJavaDoc(memberCtx), commas.get(0).getSymbol()); // all but the first and last part range from name to comma for (int i = 1; i < size - 1; i++) { final FieldNamePartContext namePart = nameParts.get(i); this.addCodeFragment(CLASS + '/' + this.className + '/' + ATTRIBUTE + '/' + namePart.IDENTIFIER().getText(), - namePart.getStart(), commas.get(i).getSymbol()); + this.getStartOrJavaDoc(namePart), commas.get(i).getSymbol()); } // last part includes semicolon final FieldNamePartContext lastPart = nameParts.get(size - 1); this.addCodeFragment(CLASS + '/' + this.className + '/' + ATTRIBUTE + '/' + lastPart.IDENTIFIER().getText(), - lastPart.getStart(), memberCtx.getStop()); + this.getStartOrJavaDoc(lastPart), memberCtx.getStop()); } @Override From a4a223c610ac9b1f81773f1be917322f1914a481 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 15:01:44 +0200 Subject: [PATCH 06/28] feat: Add Attribute.description property --- .../java/org/fulib/classmodel/GenModel.java | 1 + .../java/org/fulib/classmodel/Attribute.java | 35 +++++++++++++++++++ .../java/org/fulib/classmodel/classModel.yaml | 11 +++++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/gen/java/org/fulib/classmodel/GenModel.java b/src/gen/java/org/fulib/classmodel/GenModel.java index 51fa04bd..ecdb55a3 100644 --- a/src/gen/java/org/fulib/classmodel/GenModel.java +++ b/src/gen/java/org/fulib/classmodel/GenModel.java @@ -32,6 +32,7 @@ public void decorate(ClassModelManager mb) c.attribute("initialization", STRING); c.attribute("propertyStyle", STRING); c.attribute("modified", BOOLEAN); + c.attribute("description", STRING); }); final Clazz AssocRole = mb.haveClass("AssocRole", c -> { diff --git a/src/main/java/org/fulib/classmodel/Attribute.java b/src/main/java/org/fulib/classmodel/Attribute.java index 53d5806b..ade08b58 100644 --- a/src/main/java/org/fulib/classmodel/Attribute.java +++ b/src/main/java/org/fulib/classmodel/Attribute.java @@ -23,6 +23,8 @@ public class Attribute public static final String PROPERTY_collectionType = "collectionType"; public static final String PROPERTY_initialization = "initialization"; public static final String PROPERTY_propertyStyle = "propertyStyle"; + /** @since 1.3 */ + public static final String PROPERTY_description = "description"; public static final String PROPERTY_modified = "modified"; public static final String PROPERTY_clazz = "clazz"; @@ -36,6 +38,7 @@ public class Attribute private CollectionType collectionType; private String initialization; private String propertyStyle; + private String description; private boolean modified; private String typeSignature; @@ -233,6 +236,37 @@ public Attribute setPropertyStyle(String value) return this; } + /** + * @return the description of this attribute, used for generating JavaDocs + * + * @since 1.3 + */ + public String getDescription() + { + return this.description; + } + + /** + * @param value + * the description of this attribute, used for generating JavaDocs + * + * @return this instance, to allow method chaining + * + * @since 1.3 + */ + public Attribute setDescription(String value) + { + if (Objects.equals(value, this.description)) + { + return this; + } + + final String oldValue = this.description; + this.description = value; + this.firePropertyChange(PROPERTY_description, oldValue, value); + return this; + } + /** * @return a boolean indicating whether this attribute was modified. For internal use only. */ @@ -334,6 +368,7 @@ public String toString() result.append(' ').append(this.getType()); result.append(' ').append(this.getInitialization()); result.append(' ').append(this.getPropertyStyle()); + result.append(' ').append(this.getDescription()); return result.substring(1); } } diff --git a/src/main/java/org/fulib/classmodel/classModel.yaml b/src/main/java/org/fulib/classmodel/classModel.yaml index ddcf75f2..d53ac0e5 100644 --- a/src/main/java/org/fulib/classmodel/classModel.yaml +++ b/src/main/java/org/fulib/classmodel/classModel.yaml @@ -24,7 +24,7 @@ roles: clazz_model clazz_attributes clazz_roles clazz_methods clazz_superClass clazz_subClasses - attribute: Clazz - attributes: attribute_name attribute_type attribute_collectionType attribute_initialization attribute_propertyStyle attribute_modified + attributes: attribute_name attribute_type attribute_collectionType attribute_initialization attribute_propertyStyle attribute_modified attribute_description model: c modified: false name: Attribute @@ -298,6 +298,15 @@ type: boolean typeSignature: boolean +- attribute_description: Attribute + clazz: attribute + id: Attribute_description + modified: false + name: description + propertyStyle: Bean + type: String + typeSignature: String + - attribute_clazz: AssocRole aggregation: false cardinality: 1 From b0e3f5a6b7f887f2fd22d3b05be87d6a76c15ed7 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 15:18:48 +0200 Subject: [PATCH 07/28] feat: Add Attribute.getDescriptionLines helper --- src/main/java/org/fulib/classmodel/Attribute.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/fulib/classmodel/Attribute.java b/src/main/java/org/fulib/classmodel/Attribute.java index ade08b58..d32afc9a 100644 --- a/src/main/java/org/fulib/classmodel/Attribute.java +++ b/src/main/java/org/fulib/classmodel/Attribute.java @@ -267,6 +267,16 @@ public Attribute setDescription(String value) return this; } + /** + * @return the lines of the description of this attribute, used for generating JavaDocs + * + * @since 1.3 + */ + public String[] getDescriptionLines() + { + return this.getDescription() == null ? null : this.getDescription().split("\n"); + } + /** * @return a boolean indicating whether this attribute was modified. For internal use only. */ From f4479665e077b882e1df29a78e388961aecd64a8 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 15:54:52 +0200 Subject: [PATCH 08/28] feat: Generate JavaDocs from descriptions in attribute templates --- .../org/fulib/templates/attributes.bean.stg | 3 +++ .../org/fulib/templates/attributes.javafx.stg | 9 ++++++++ .../org/fulib/templates/attributes.pojo.stg | 23 +++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/src/main/resources/org/fulib/templates/attributes.bean.stg b/src/main/resources/org/fulib/templates/attributes.bean.stg index 2f0a647a..626b7649 100644 --- a/src/main/resources/org/fulib/templates/attributes.bean.stg +++ b/src/main/resources/org/fulib/templates/attributes.bean.stg @@ -3,6 +3,9 @@ import "attributes.pojo.stg" // --------------- Simple Accessors --------------- attrSet(attr) ::= << + + + public set( value) { if (value == this.import(java.util.Objects).equals(value, this.)) diff --git a/src/main/resources/org/fulib/templates/attributes.javafx.stg b/src/main/resources/org/fulib/templates/attributes.javafx.stg index 9c5d3a00..b88ea82d 100644 --- a/src/main/resources/org/fulib/templates/attributes.javafx.stg +++ b/src/main/resources/org/fulib/templates/attributes.javafx.stg @@ -24,6 +24,9 @@ initMethod(attr) ::= << >> attrGet(attr) ::= << + + + public java.util.List\<\> get() @@ -35,6 +38,9 @@ attrGet(attr) ::= << >> attrSet(attr) ::= << + + + public set( value) { if (value != this..getValue()!import(java.util.Objects).equals(value, this..getValue())) @@ -46,6 +52,9 @@ attrSet(attr) ::= << >> propertyGet(attr) ::= << + + + public Property() { return this.; diff --git a/src/main/resources/org/fulib/templates/attributes.pojo.stg b/src/main/resources/org/fulib/templates/attributes.pojo.stg index e6f3a0b2..06629fa9 100644 --- a/src/main/resources/org/fulib/templates/attributes.pojo.stg +++ b/src/main/resources/org/fulib/templates/attributes.pojo.stg @@ -47,9 +47,29 @@ propertyDecl(attr) ::= << public static final String PROPERTY_ = ""; >> +// --------------- JavaDocs --------------- + +getterJavaDoc(attr) ::= << +/** + * @return + */ +>> + +setterJavaDoc(attr) ::= << +/** + * @param value + * + * + * @return this + */ +>> + // --------------- Simple Accessors --------------- attrGet(attr) ::= << + + + public get() { @@ -61,6 +81,9 @@ attrGet(attr) ::= << >> attrSet(attr) ::= << + + + public set( value) { this. = value; From 67343c2a43977e000f9012ccb4fe56e5255de194 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 15:57:37 +0200 Subject: [PATCH 09/28] feat: Add descriptions in GenModel --- .../java/org/fulib/classmodel/GenModel.java | 54 ++++++++++++++----- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/src/gen/java/org/fulib/classmodel/GenModel.java b/src/gen/java/org/fulib/classmodel/GenModel.java index ecdb55a3..ca6bb257 100644 --- a/src/gen/java/org/fulib/classmodel/GenModel.java +++ b/src/gen/java/org/fulib/classmodel/GenModel.java @@ -14,39 +14,67 @@ public void decorate(ClassModelManager mb) final Clazz ClassModel = mb.haveClass("ClassModel", c -> { c.attribute("packageName", STRING); c.attribute("mainJavaDir", STRING); - c.attribute("defaultCollectionType", "CollectionType"); - c.attribute("defaultPropertyStyle", STRING, "\"POJO\""); + c + .attribute("defaultCollectionType", "CollectionType") + .setDescription("the default collection type for to-n roles"); + c + .attribute("defaultPropertyStyle", STRING, "\"POJO\"") + .setDescription("the default property style to use for attributes and roles.\n" + + "Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported."); }); final Clazz Clazz = mb.haveClass("Clazz", c -> { c.attribute("name", STRING); - c.attribute("propertyStyle", STRING); - c.attribute("modified", BOOLEAN); + c + .attribute("propertyStyle", STRING) + .setDescription("the default property style to use for attributes and roles.\n" + + "Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported."); + c + .attribute("modified", BOOLEAN) + .setDescription("a boolean indicating whether this attribute was modified. For internal use only."); c.attribute("imports", STRING).setCollectionType(CollectionType.LinkedHashSet); }); final Clazz Attribute = mb.haveClass("Attribute", c -> { c.attribute("name", STRING); c.attribute("type", STRING); - c.attribute("collectionType", "CollectionType"); + c.attribute("collectionType", "CollectionType").setDescription("the collection type"); c.attribute("initialization", STRING); - c.attribute("propertyStyle", STRING); - c.attribute("modified", BOOLEAN); - c.attribute("description", STRING); + c + .attribute("propertyStyle", STRING) + .setDescription("the property style to use for this attribute.\n" + + "Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported."); + c + .attribute("modified", BOOLEAN) + .setDescription("a boolean indicating whether this attribute was modified. For internal use only."); + c + .attribute("description", STRING) + .setDescription("the description of this attribute, used for generating JavaDocs"); }); final Clazz AssocRole = mb.haveClass("AssocRole", c -> { c.attribute("name", STRING); c.attribute("cardinality", INT); - c.attribute("collectionType", "CollectionType"); - c.attribute("aggregation", BOOLEAN); - c.attribute("propertyStyle", STRING); - c.attribute("modified", BOOLEAN); + c.attribute("collectionType", "CollectionType").setDescription("the collection type"); + c + .attribute("aggregation", BOOLEAN) + .setDescription("a boolean indicating whether this role is an aggregation,\n" + + "i.e. whether the target objects are {@code removeYou}'d completely when using {@code without*} methods or\n" + + "{@code removeYou} on the source object"); + c + .attribute("propertyStyle", STRING) + .setDescription("the property style to use for this role.\n" + + "Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported."); + c + .attribute("modified", BOOLEAN) + .setDescription("a boolean indicating whether this role was modified. For internal use only."); }); final Clazz FMethod = mb.haveClass("FMethod", c -> { c.attribute("methodBody", STRING); - c.attribute("modified", BOOLEAN); + c + .attribute("modified", BOOLEAN) + .setDescription("a boolean indicating whether this method was modified. For internal use only."); c.attribute("modifiers", STRING, "\"public\""); c.attribute("annotations", STRING); }); From 5b7a72a4272c170465bc74e9274f6d05442c5e3d Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 16:03:59 +0200 Subject: [PATCH 10/28] feat: Add Attribute.since property --- .../java/org/fulib/classmodel/GenModel.java | 3 ++ .../java/org/fulib/classmodel/Attribute.java | 32 +++++++++++++++++++ .../java/org/fulib/classmodel/classModel.yaml | 13 +++++++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/gen/java/org/fulib/classmodel/GenModel.java b/src/gen/java/org/fulib/classmodel/GenModel.java index ca6bb257..b332726d 100644 --- a/src/gen/java/org/fulib/classmodel/GenModel.java +++ b/src/gen/java/org/fulib/classmodel/GenModel.java @@ -50,6 +50,9 @@ public void decorate(ClassModelManager mb) c .attribute("description", STRING) .setDescription("the description of this attribute, used for generating JavaDocs"); + c + .attribute("since", STRING) + .setDescription("the version when this attribute was introduced, used for generating JavaDocs"); }); final Clazz AssocRole = mb.haveClass("AssocRole", c -> { diff --git a/src/main/java/org/fulib/classmodel/Attribute.java b/src/main/java/org/fulib/classmodel/Attribute.java index d32afc9a..364996ab 100644 --- a/src/main/java/org/fulib/classmodel/Attribute.java +++ b/src/main/java/org/fulib/classmodel/Attribute.java @@ -25,6 +25,8 @@ public class Attribute public static final String PROPERTY_propertyStyle = "propertyStyle"; /** @since 1.3 */ public static final String PROPERTY_description = "description"; + /** @since 1.3 */ + public static final String PROPERTY_since = "since"; public static final String PROPERTY_modified = "modified"; public static final String PROPERTY_clazz = "clazz"; @@ -39,6 +41,7 @@ public class Attribute private String initialization; private String propertyStyle; private String description; + private String since; private boolean modified; private String typeSignature; @@ -277,6 +280,34 @@ public String[] getDescriptionLines() return this.getDescription() == null ? null : this.getDescription().split("\n"); } + + /** + * @return the version when this attribute was introduced, used for generating JavaDocs + */ + public String getSince() + { + return this.since; + } + + /** + * @param value + * the version when this attribute was introduced, used for generating JavaDocs + * + * @return this + */ + public Attribute setSince(String value) + { + if (Objects.equals(value, this.since)) + { + return this; + } + + final String oldValue = this.since; + this.since = value; + this.firePropertyChange(PROPERTY_since, oldValue, value); + return this; + } + /** * @return a boolean indicating whether this attribute was modified. For internal use only. */ @@ -379,6 +410,7 @@ public String toString() result.append(' ').append(this.getInitialization()); result.append(' ').append(this.getPropertyStyle()); result.append(' ').append(this.getDescription()); + result.append(' ').append(this.getSince()); return result.substring(1); } } diff --git a/src/main/java/org/fulib/classmodel/classModel.yaml b/src/main/java/org/fulib/classmodel/classModel.yaml index d53ac0e5..0450203f 100644 --- a/src/main/java/org/fulib/classmodel/classModel.yaml +++ b/src/main/java/org/fulib/classmodel/classModel.yaml @@ -24,7 +24,7 @@ roles: clazz_model clazz_attributes clazz_roles clazz_methods clazz_superClass clazz_subClasses - attribute: Clazz - attributes: attribute_name attribute_type attribute_collectionType attribute_initialization attribute_propertyStyle attribute_modified attribute_description + attributes: attribute_name attribute_type attribute_collectionType attribute_initialization attribute_propertyStyle attribute_modified attribute_description attribute_since model: c modified: false name: Attribute @@ -307,6 +307,17 @@ type: String typeSignature: String +- attribute_since: Attribute + clazz: attribute + description: "the version when this attribute was introduced, used for generating JavaDocs" + descriptionLines: [Ljava.lang.String;@de3a06f + id: Attribute_since + modified: false + name: since + propertyStyle: Bean + type: String + typeSignature: String + - attribute_clazz: AssocRole aggregation: false cardinality: 1 From 208b47d38cb95d3c6de962be0fde7ad7ba4889e0 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 16:14:32 +0200 Subject: [PATCH 11/28] feat: Generate @since in JavaDoc templates --- .../resources/org/fulib/templates/attributes.pojo.stg | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/resources/org/fulib/templates/attributes.pojo.stg b/src/main/resources/org/fulib/templates/attributes.pojo.stg index 06629fa9..6f93d5b1 100644 --- a/src/main/resources/org/fulib/templates/attributes.pojo.stg +++ b/src/main/resources/org/fulib/templates/attributes.pojo.stg @@ -52,6 +52,10 @@ propertyDecl(attr) ::= << getterJavaDoc(attr) ::= << /** * @return + + * + * @since + */ >> @@ -61,6 +65,10 @@ setterJavaDoc(attr) ::= << * * * @return this + + * + * @since + */ >> From 7b8024bf16c2733ea50819aa40b10da57626fc63 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 16:22:08 +0200 Subject: [PATCH 12/28] feat: Set since in GenModel --- .../java/org/fulib/classmodel/GenModel.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gen/java/org/fulib/classmodel/GenModel.java b/src/gen/java/org/fulib/classmodel/GenModel.java index b332726d..66b0983e 100644 --- a/src/gen/java/org/fulib/classmodel/GenModel.java +++ b/src/gen/java/org/fulib/classmodel/GenModel.java @@ -16,7 +16,8 @@ public void decorate(ClassModelManager mb) c.attribute("mainJavaDir", STRING); c .attribute("defaultCollectionType", "CollectionType") - .setDescription("the default collection type for to-n roles"); + .setDescription("the default collection type for to-n roles") + .setSince("1.2"); c .attribute("defaultPropertyStyle", STRING, "\"POJO\"") .setDescription("the default property style to use for attributes and roles.\n" @@ -38,7 +39,7 @@ public void decorate(ClassModelManager mb) final Clazz Attribute = mb.haveClass("Attribute", c -> { c.attribute("name", STRING); c.attribute("type", STRING); - c.attribute("collectionType", "CollectionType").setDescription("the collection type"); + c.attribute("collectionType", "CollectionType").setDescription("the collection type").setSince("1.2"); c.attribute("initialization", STRING); c .attribute("propertyStyle", STRING) @@ -49,16 +50,18 @@ public void decorate(ClassModelManager mb) .setDescription("a boolean indicating whether this attribute was modified. For internal use only."); c .attribute("description", STRING) - .setDescription("the description of this attribute, used for generating JavaDocs"); + .setDescription("the description of this attribute, used for generating JavaDocs") + .setSince("1.3"); c .attribute("since", STRING) - .setDescription("the version when this attribute was introduced, used for generating JavaDocs"); + .setDescription("the version when this attribute was introduced, used for generating JavaDocs") + .setSince("1.3"); }); final Clazz AssocRole = mb.haveClass("AssocRole", c -> { c.attribute("name", STRING); c.attribute("cardinality", INT); - c.attribute("collectionType", "CollectionType").setDescription("the collection type"); + c.attribute("collectionType", "CollectionType").setDescription("the collection type").setSince("1.2"); c .attribute("aggregation", BOOLEAN) .setDescription("a boolean indicating whether this role is an aggregation,\n" @@ -78,7 +81,10 @@ public void decorate(ClassModelManager mb) c .attribute("modified", BOOLEAN) .setDescription("a boolean indicating whether this method was modified. For internal use only."); - c.attribute("modifiers", STRING, "\"public\""); + c + .attribute("modifiers", STRING, "\"public\"") + .setDescription("the modifiers. Defaults to \"public\"") + .setSince("1.2"); c.attribute("annotations", STRING); }); From ccf5fed667c0b27450d60682090a2d54a89fecbb Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 16:22:24 +0200 Subject: [PATCH 13/28] feat: Improve descriptions in GenModel --- src/gen/java/org/fulib/classmodel/GenModel.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gen/java/org/fulib/classmodel/GenModel.java b/src/gen/java/org/fulib/classmodel/GenModel.java index 66b0983e..7981bd7d 100644 --- a/src/gen/java/org/fulib/classmodel/GenModel.java +++ b/src/gen/java/org/fulib/classmodel/GenModel.java @@ -20,7 +20,7 @@ public void decorate(ClassModelManager mb) .setSince("1.2"); c .attribute("defaultPropertyStyle", STRING, "\"POJO\"") - .setDescription("the default property style to use for attributes and roles.\n" + .setDescription("the default property style for attributes and roles.\n" + "Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported."); }); @@ -28,7 +28,7 @@ public void decorate(ClassModelManager mb) c.attribute("name", STRING); c .attribute("propertyStyle", STRING) - .setDescription("the default property style to use for attributes and roles.\n" + .setDescription("the default property style for attributes and roles.\n" + "Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported."); c .attribute("modified", BOOLEAN) @@ -43,7 +43,7 @@ public void decorate(ClassModelManager mb) c.attribute("initialization", STRING); c .attribute("propertyStyle", STRING) - .setDescription("the property style to use for this attribute.\n" + .setDescription("the property style.\n" + "Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported."); c .attribute("modified", BOOLEAN) @@ -69,7 +69,7 @@ public void decorate(ClassModelManager mb) + "{@code removeYou} on the source object"); c .attribute("propertyStyle", STRING) - .setDescription("the property style to use for this role.\n" + .setDescription("the property style.\n" + "Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported."); c .attribute("modified", BOOLEAN) From 47fb2a69cfd214881962d498b2b36b55008b84d2 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 16:23:40 +0200 Subject: [PATCH 14/28] feat: Update generated classes --- .../java/org/fulib/classmodel/AssocRole.java | 21 ++++++---- .../java/org/fulib/classmodel/Attribute.java | 20 +++++---- .../java/org/fulib/classmodel/ClassModel.java | 19 +++++++-- src/main/java/org/fulib/classmodel/Clazz.java | 22 ++++++++++ .../java/org/fulib/classmodel/FMethod.java | 16 +++++++ .../java/org/fulib/classmodel/classModel.yaml | 42 ++++++++++++++++++- 6 files changed, 119 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/fulib/classmodel/AssocRole.java b/src/main/java/org/fulib/classmodel/AssocRole.java index ac98ecdc..a7b51401 100644 --- a/src/main/java/org/fulib/classmodel/AssocRole.java +++ b/src/main/java/org/fulib/classmodel/AssocRole.java @@ -171,9 +171,9 @@ public CollectionType getCollectionType() /** * @param value - * the new collection type + * the collection type * - * @return this instance, to allow method chaining + * @return this * * @since 1.2 */ @@ -217,7 +217,8 @@ public AssocRole setRoleType(String value) /** * @return a boolean indicating whether this role is an aggregation, - * i.e. whether the target objects are {@code removeYou}'d completely when using {@code without*} methods or {@code removeYou} on the source object + * i.e. whether the target objects are {@code removeYou}'d completely when using {@code without*} methods or + * {@code removeYou} on the source object */ public boolean getAggregation() { @@ -227,9 +228,10 @@ public boolean getAggregation() /** * @param value * a boolean indicating whether this role is an aggregation, - * i.e. whether the target objects are {@code removeYou}'d completely when using {@code without*} methods or {@code removeYou} on the source object + * i.e. whether the target objects are {@code removeYou}'d completely when using {@code without*} methods or + * {@code removeYou} on the source object * - * @return this instance, to allow method chaining + * @return this */ public AssocRole setAggregation(boolean value) { @@ -245,7 +247,8 @@ public AssocRole setAggregation(boolean value) } /** - * @return the property style of this role + * @return the property style. + * Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported. */ public String getPropertyStyle() { @@ -254,10 +257,10 @@ public String getPropertyStyle() /** * @param value - * the property style to use for this role. + * the property style. * Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported. * - * @return this instance, to allow method chaining + * @return this */ public AssocRole setPropertyStyle(String value) { @@ -284,7 +287,7 @@ public boolean getModified() * @param value * a boolean indicating whether this role was modified. For internal use only. * - * @return this instance, to allow method chaining + * @return this */ public AssocRole setModified(boolean value) { diff --git a/src/main/java/org/fulib/classmodel/Attribute.java b/src/main/java/org/fulib/classmodel/Attribute.java index 364996ab..d96b14f8 100644 --- a/src/main/java/org/fulib/classmodel/Attribute.java +++ b/src/main/java/org/fulib/classmodel/Attribute.java @@ -164,9 +164,9 @@ public CollectionType getCollectionType() /** * @param value - * the new collection type + * the collection type * - * @return this instance, to allow method chaining + * @return this * * @since 1.2 */ @@ -212,7 +212,8 @@ public Attribute setInitialization(String value) } /** - * @return the property style of this attribute + * @return the property style. + * Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported. */ public String getPropertyStyle() { @@ -221,10 +222,10 @@ public String getPropertyStyle() /** * @param value - * the property style to use for this attribute. + * the property style. * Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported. * - * @return this instance, to allow method chaining + * @return this */ public Attribute setPropertyStyle(String value) { @@ -253,7 +254,7 @@ public String getDescription() * @param value * the description of this attribute, used for generating JavaDocs * - * @return this instance, to allow method chaining + * @return this * * @since 1.3 */ @@ -280,9 +281,10 @@ public String[] getDescriptionLines() return this.getDescription() == null ? null : this.getDescription().split("\n"); } - /** * @return the version when this attribute was introduced, used for generating JavaDocs + * + * @since 1.3 */ public String getSince() { @@ -294,6 +296,8 @@ public String getSince() * the version when this attribute was introduced, used for generating JavaDocs * * @return this + * + * @since 1.3 */ public Attribute setSince(String value) { @@ -320,7 +324,7 @@ public boolean getModified() * @param value * a boolean indicating whether this attribute was modified. For internal use only. * - * @return this instance, to allow method chaining + * @return this */ public Attribute setModified(boolean value) { diff --git a/src/main/java/org/fulib/classmodel/ClassModel.java b/src/main/java/org/fulib/classmodel/ClassModel.java index 11a8cfb5..965f874d 100644 --- a/src/main/java/org/fulib/classmodel/ClassModel.java +++ b/src/main/java/org/fulib/classmodel/ClassModel.java @@ -1,5 +1,7 @@ package org.fulib.classmodel; +import org.fulib.builder.Type; + import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.util.ArrayList; @@ -82,7 +84,7 @@ public ClassModel setPackageName(String value) } /** - * @return the default collection type + * @return the default collection type for to-n roles * * @since 1.2 */ @@ -93,9 +95,9 @@ public CollectionType getDefaultCollectionType() /** * @param value - * the new default collection type + * the default collection type for to-n roles * - * @return this instance, to allow method chaining + * @return this * * @since 1.2 */ @@ -138,11 +140,22 @@ public ClassModel setDefaultRoleType(String value) return this.setDefaultCollectionType(CollectionType.of(value)); } + /** + * @return the default property style for attributes and roles. + * Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported. + */ public String getDefaultPropertyStyle() { return this.defaultPropertyStyle; } + /** + * @param value + * the default property style for attributes and roles. + * Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported. + * + * @return this + */ public ClassModel setDefaultPropertyStyle(String value) { if (Objects.equals(value, this.defaultPropertyStyle)) diff --git a/src/main/java/org/fulib/classmodel/Clazz.java b/src/main/java/org/fulib/classmodel/Clazz.java index 0690a650..b0101aad 100644 --- a/src/main/java/org/fulib/classmodel/Clazz.java +++ b/src/main/java/org/fulib/classmodel/Clazz.java @@ -1,5 +1,7 @@ package org.fulib.classmodel; +import org.fulib.builder.Type; + import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.util.ArrayList; @@ -762,11 +764,22 @@ public Clazz withoutImports(Collection value) return this; } + /** + * @return the default property style for attributes and roles. + * Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported. + */ public String getPropertyStyle() { return this.propertyStyle; } + /** + * @param value + * the default property style for attributes and roles. + * Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported. + * + * @return this + */ public Clazz setPropertyStyle(String value) { if (Objects.equals(value, this.propertyStyle)) @@ -780,11 +793,20 @@ public Clazz setPropertyStyle(String value) return this; } + /** + * @return a boolean indicating whether this attribute was modified. For internal use only. + */ public boolean getModified() { return this.modified; } + /** + * @param value + * a boolean indicating whether this attribute was modified. For internal use only. + * + * @return this + */ public Clazz setModified(boolean value) { if (value == this.modified) diff --git a/src/main/java/org/fulib/classmodel/FMethod.java b/src/main/java/org/fulib/classmodel/FMethod.java index dce53222..5057966a 100644 --- a/src/main/java/org/fulib/classmodel/FMethod.java +++ b/src/main/java/org/fulib/classmodel/FMethod.java @@ -217,6 +217,8 @@ public FMethod setAnnotations(String value) } /** + * @return the modifiers. Defaults to "public" + * * @since 1.2 */ public String getModifiers() @@ -225,6 +227,11 @@ public String getModifiers() } /** + * @param value + * the modifiers. Defaults to "public" + * + * @return this + * * @since 1.2 */ public FMethod setModifiers(String value) @@ -328,11 +335,20 @@ public FMethod setMethodBody(String value) return this; } + /** + * @return a boolean indicating whether this method was modified. For internal use only. + */ public boolean getModified() { return this.modified; } + /** + * @param value + * a boolean indicating whether this method was modified. For internal use only. + * + * @return this + */ public FMethod setModified(boolean value) { if (value == this.modified) diff --git a/src/main/java/org/fulib/classmodel/classModel.yaml b/src/main/java/org/fulib/classmodel/classModel.yaml index 0450203f..6f119749 100644 --- a/src/main/java/org/fulib/classmodel/classModel.yaml +++ b/src/main/java/org/fulib/classmodel/classModel.yaml @@ -106,15 +106,21 @@ - classModel_defaultCollectionType: Attribute clazz: classModel + description: "the default collection type for to-n roles" + descriptionLines: [Ljava.lang.String;@5e955596 id: ClassModel_defaultCollectionType modified: false name: defaultCollectionType propertyStyle: Bean + since: 1.2 type: CollectionType typeSignature: CollectionType - classModel_defaultPropertyStyle: Attribute clazz: classModel + description: "the default property style for attributes and roles. +Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported." + descriptionLines: [Ljava.lang.String;@50de0926 id: ClassModel_defaultPropertyStyle initialization: "\"POJO\"" modified: false @@ -146,6 +152,9 @@ - clazz_propertyStyle: Attribute clazz: clazz + description: "the default property style for attributes and roles. +Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported." + descriptionLines: [Ljava.lang.String;@2473b9ce id: Clazz_propertyStyle modified: false name: propertyStyle @@ -155,6 +164,8 @@ - clazz_modified: Attribute clazz: clazz + description: "a boolean indicating whether this attribute was modified. For internal use only." + descriptionLines: [Ljava.lang.String;@60438a68 id: Clazz_modified modified: false name: modified @@ -264,10 +275,13 @@ - attribute_collectionType: Attribute clazz: attribute + description: "the collection type" + descriptionLines: [Ljava.lang.String;@17695df3 id: Attribute_collectionType modified: false name: collectionType propertyStyle: Bean + since: 1.2 type: CollectionType typeSignature: CollectionType @@ -282,6 +296,9 @@ - attribute_propertyStyle: Attribute clazz: attribute + description: "the property style. +Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported." + descriptionLines: [Ljava.lang.String;@6c9f5c0d id: Attribute_propertyStyle modified: false name: propertyStyle @@ -291,6 +308,8 @@ - attribute_modified: Attribute clazz: attribute + description: "a boolean indicating whether this attribute was modified. For internal use only." + descriptionLines: [Ljava.lang.String;@de3a06f id: Attribute_modified modified: false name: modified @@ -300,21 +319,25 @@ - attribute_description: Attribute clazz: attribute + description: "the description of this attribute, used for generating JavaDocs" + descriptionLines: [Ljava.lang.String;@76b10754 id: Attribute_description modified: false name: description propertyStyle: Bean + since: 1.3 type: String typeSignature: String - attribute_since: Attribute clazz: attribute description: "the version when this attribute was introduced, used for generating JavaDocs" - descriptionLines: [Ljava.lang.String;@de3a06f + descriptionLines: [Ljava.lang.String;@2bea5ab4 id: Attribute_since modified: false name: since propertyStyle: Bean + since: 1.3 type: String typeSignature: String @@ -350,15 +373,22 @@ - assocRole_collectionType: Attribute clazz: assocRole + description: "the collection type" + descriptionLines: [Ljava.lang.String;@3d8314f0 id: AssocRole_collectionType modified: false name: collectionType propertyStyle: Bean + since: 1.2 type: CollectionType typeSignature: CollectionType - assocRole_aggregation: Attribute clazz: assocRole + description: "a boolean indicating whether this role is an aggregation, +i.e. whether the target objects are {@code removeYou}'d completely when using {@code without*} methods or +{@code removeYou} on the source object" + descriptionLines: [Ljava.lang.String;@2df32bf7 id: AssocRole_aggregation modified: false name: aggregation @@ -368,6 +398,9 @@ - assocRole_propertyStyle: Attribute clazz: assocRole + description: "the property style. +Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported." + descriptionLines: [Ljava.lang.String;@530612ba id: AssocRole_propertyStyle modified: false name: propertyStyle @@ -377,6 +410,8 @@ - assocRole_modified: Attribute clazz: assocRole + description: "a boolean indicating whether this role was modified. For internal use only." + descriptionLines: [Ljava.lang.String;@2a40cd94 id: AssocRole_modified modified: false name: modified @@ -419,6 +454,8 @@ - fMethod_modified: Attribute clazz: fMethod + description: "a boolean indicating whether this method was modified. For internal use only." + descriptionLines: [Ljava.lang.String;@f4168b8 id: FMethod_modified modified: false name: modified @@ -428,11 +465,14 @@ - fMethod_modifiers: Attribute clazz: fMethod + description: "the modifiers. Defaults to \"public\"" + descriptionLines: [Ljava.lang.String;@3bd94634 id: FMethod_modifiers initialization: "\"public\"" modified: false name: modifiers propertyStyle: Bean + since: 1.2 type: String typeSignature: String From 414a922f4a7c2bc03743d50f6fefba13a645524e Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 16:32:37 +0200 Subject: [PATCH 15/28] feat: Generate JavaDoc with @since 1.2 for PROPERTY_* constants --- src/main/java/org/fulib/classmodel/ClassModel.java | 1 + src/main/resources/org/fulib/templates/attributes.pojo.stg | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/main/java/org/fulib/classmodel/ClassModel.java b/src/main/java/org/fulib/classmodel/ClassModel.java index 965f874d..78f09bc2 100644 --- a/src/main/java/org/fulib/classmodel/ClassModel.java +++ b/src/main/java/org/fulib/classmodel/ClassModel.java @@ -24,6 +24,7 @@ public class ClassModel /** @deprecated since 1.2; use {@link #PROPERTY_defaultCollectionType} instead */ @Deprecated public static final String PROPERTY_defaultRoleType = "defaultRoleType"; + /** @since 1.2 */ public static final String PROPERTY_defaultCollectionType = "defaultCollectionType"; public static final String PROPERTY_defaultPropertyStyle = "defaultPropertyStyle"; public static final String PROPERTY_classes = "classes"; diff --git a/src/main/resources/org/fulib/templates/attributes.pojo.stg b/src/main/resources/org/fulib/templates/attributes.pojo.stg index 6f93d5b1..63592d47 100644 --- a/src/main/resources/org/fulib/templates/attributes.pojo.stg +++ b/src/main/resources/org/fulib/templates/attributes.pojo.stg @@ -44,6 +44,9 @@ attrDecl(attr) ::= << >> propertyDecl(attr) ::= << + + /** @since */ + public static final String PROPERTY_ = ""; >> From 0d2ceae51758d286ed8cace504e752d186c8bf78 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 16:34:41 +0200 Subject: [PATCH 16/28] fix: Make Attribute.getDescriptionLines return a list fulibYaml serializes arrays as e.g. [Ljava.lang.String;@7f416310. The classModel.yaml constantly changed due to the random ID. --- src/main/java/org/fulib/classmodel/Attribute.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/fulib/classmodel/Attribute.java b/src/main/java/org/fulib/classmodel/Attribute.java index d96b14f8..4432a453 100644 --- a/src/main/java/org/fulib/classmodel/Attribute.java +++ b/src/main/java/org/fulib/classmodel/Attribute.java @@ -11,6 +11,9 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import java.util.Objects; public class Attribute @@ -276,9 +279,9 @@ public Attribute setDescription(String value) * * @since 1.3 */ - public String[] getDescriptionLines() + public List getDescriptionLines() { - return this.getDescription() == null ? null : this.getDescription().split("\n"); + return this.getDescription() == null ? Collections.emptyList() : Arrays.asList(this.getDescription().split("\n")); } /** From dc4ed8eddf05d6094c154327e53db5141921bae6 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 16:35:18 +0200 Subject: [PATCH 17/28] chore: Update classModel.yaml --- .../java/org/fulib/classmodel/classModel.yaml | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/fulib/classmodel/classModel.yaml b/src/main/java/org/fulib/classmodel/classModel.yaml index 6f119749..96aa8a31 100644 --- a/src/main/java/org/fulib/classmodel/classModel.yaml +++ b/src/main/java/org/fulib/classmodel/classModel.yaml @@ -107,7 +107,7 @@ - classModel_defaultCollectionType: Attribute clazz: classModel description: "the default collection type for to-n roles" - descriptionLines: [Ljava.lang.String;@5e955596 + descriptionLines: "the default collection type for to-n roles" id: ClassModel_defaultCollectionType modified: false name: defaultCollectionType @@ -120,7 +120,7 @@ clazz: classModel description: "the default property style for attributes and roles. Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported." - descriptionLines: [Ljava.lang.String;@50de0926 + descriptionLines: "the default property style for attributes and roles." "Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported." id: ClassModel_defaultPropertyStyle initialization: "\"POJO\"" modified: false @@ -154,7 +154,7 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar clazz: clazz description: "the default property style for attributes and roles. Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported." - descriptionLines: [Ljava.lang.String;@2473b9ce + descriptionLines: "the default property style for attributes and roles." "Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported." id: Clazz_propertyStyle modified: false name: propertyStyle @@ -165,7 +165,7 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar - clazz_modified: Attribute clazz: clazz description: "a boolean indicating whether this attribute was modified. For internal use only." - descriptionLines: [Ljava.lang.String;@60438a68 + descriptionLines: "a boolean indicating whether this attribute was modified. For internal use only." id: Clazz_modified modified: false name: modified @@ -276,7 +276,7 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar - attribute_collectionType: Attribute clazz: attribute description: "the collection type" - descriptionLines: [Ljava.lang.String;@17695df3 + descriptionLines: "the collection type" id: Attribute_collectionType modified: false name: collectionType @@ -298,7 +298,7 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar clazz: attribute description: "the property style. Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported." - descriptionLines: [Ljava.lang.String;@6c9f5c0d + descriptionLines: "the property style." "Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported." id: Attribute_propertyStyle modified: false name: propertyStyle @@ -309,7 +309,7 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar - attribute_modified: Attribute clazz: attribute description: "a boolean indicating whether this attribute was modified. For internal use only." - descriptionLines: [Ljava.lang.String;@de3a06f + descriptionLines: "a boolean indicating whether this attribute was modified. For internal use only." id: Attribute_modified modified: false name: modified @@ -320,7 +320,7 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar - attribute_description: Attribute clazz: attribute description: "the description of this attribute, used for generating JavaDocs" - descriptionLines: [Ljava.lang.String;@76b10754 + descriptionLines: "the description of this attribute, used for generating JavaDocs" id: Attribute_description modified: false name: description @@ -332,7 +332,7 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar - attribute_since: Attribute clazz: attribute description: "the version when this attribute was introduced, used for generating JavaDocs" - descriptionLines: [Ljava.lang.String;@2bea5ab4 + descriptionLines: "the version when this attribute was introduced, used for generating JavaDocs" id: Attribute_since modified: false name: since @@ -374,7 +374,7 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar - assocRole_collectionType: Attribute clazz: assocRole description: "the collection type" - descriptionLines: [Ljava.lang.String;@3d8314f0 + descriptionLines: "the collection type" id: AssocRole_collectionType modified: false name: collectionType @@ -388,7 +388,7 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar description: "a boolean indicating whether this role is an aggregation, i.e. whether the target objects are {@code removeYou}'d completely when using {@code without*} methods or {@code removeYou} on the source object" - descriptionLines: [Ljava.lang.String;@2df32bf7 + descriptionLines: "a boolean indicating whether this role is an aggregation," "i.e. whether the target objects are {@code removeYou}'d completely when using {@code without*} methods or" "{@code removeYou} on the source object" id: AssocRole_aggregation modified: false name: aggregation @@ -400,7 +400,7 @@ i.e. whether the target objects are {@code removeYou}'d completely when using {@ clazz: assocRole description: "the property style. Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported." - descriptionLines: [Ljava.lang.String;@530612ba + descriptionLines: "the property style." "Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported." id: AssocRole_propertyStyle modified: false name: propertyStyle @@ -411,7 +411,7 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar - assocRole_modified: Attribute clazz: assocRole description: "a boolean indicating whether this role was modified. For internal use only." - descriptionLines: [Ljava.lang.String;@2a40cd94 + descriptionLines: "a boolean indicating whether this role was modified. For internal use only." id: AssocRole_modified modified: false name: modified @@ -455,7 +455,7 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar - fMethod_modified: Attribute clazz: fMethod description: "a boolean indicating whether this method was modified. For internal use only." - descriptionLines: [Ljava.lang.String;@f4168b8 + descriptionLines: "a boolean indicating whether this method was modified. For internal use only." id: FMethod_modified modified: false name: modified @@ -466,7 +466,7 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar - fMethod_modifiers: Attribute clazz: fMethod description: "the modifiers. Defaults to \"public\"" - descriptionLines: [Ljava.lang.String;@3bd94634 + descriptionLines: "the modifiers. Defaults to \"public\"" id: FMethod_modifiers initialization: "\"public\"" modified: false From b591001700424aa08a2f604b0aade899dd29721e Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 17:02:57 +0200 Subject: [PATCH 18/28] fix: Restore backwards compatibility in FragmentMapBuilder --- .../org/fulib/parser/FragmentMapBuilder.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/fulib/parser/FragmentMapBuilder.java b/src/main/java/org/fulib/parser/FragmentMapBuilder.java index 67968803..6f773fd7 100644 --- a/src/main/java/org/fulib/parser/FragmentMapBuilder.java +++ b/src/main/java/org/fulib/parser/FragmentMapBuilder.java @@ -35,7 +35,21 @@ public class FragmentMapBuilder extends FulibClassBaseListener // =============== Constructors =============== - public FragmentMapBuilder(CharStream input, CommonTokenStream tokenStream, FileFragmentMap map) + /** + * @param input + * the character input + * @param map + * the fragment map that should be populated + * + * @deprecated since 1.3; for internal use only - use one of the public static methods + */ + @Deprecated + public FragmentMapBuilder(CharStream input, FileFragmentMap map) + { + this(input, null, map); + } + + private FragmentMapBuilder(CharStream input, CommonTokenStream tokenStream, FileFragmentMap map) { this.input = input; this.tokenStream = tokenStream; @@ -251,6 +265,14 @@ public void enterMethodMember(MethodMemberContext ctx) private Token getStartOrJavaDoc(ParserRuleContext memberCtx) { final Token start = memberCtx.getStart(); + + // TODO remove if statement when removing the public constructor in v2 + if (this.tokenStream == null) + { + // for compatibility, the constructor without the tokenStream parameter is still available. + return start; + } + for (int i = start.getTokenIndex() - 1; i >= 0; i--) { final Token prev = this.tokenStream.get(i); From 205e828922e438e72f3d29ab79337fcde4c15782 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 17:03:29 +0200 Subject: [PATCH 19/28] fix: Ignore revapi breaking change in FulibClassLexer --- .palantir/revapi.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.palantir/revapi.yml b/.palantir/revapi.yml index ac3fc8c6..cd3a7277 100644 --- a/.palantir/revapi.yml +++ b/.palantir/revapi.yml @@ -9,6 +9,10 @@ acceptedBreaks: old: "field org.fulib.classmodel.FileFragmentMap.PACKAGE_NEWLINES" new: "field org.fulib.classmodel.FileFragmentMap.PACKAGE_NEWLINES" justification: "https://github.com/fujaba/fulib/pull/36" + - code: "java.field.constantValueChanged" + old: "field org.fulib.parser.FulibClassLexer._serializedATN" + new: "field org.fulib.parser.FulibClassLexer._serializedATN" + justification: "ANTLR-generated org.fulib.parser classes are for internal use only" - code: "java.field.constantValueChanged" old: "field org.fulib.parser.FulibClassParser.RULE_annotatedType" new: "field org.fulib.parser.FulibClassParser.RULE_annotatedType" From 40bffa64d7ce4354c21442a651a4e7bcf01d0ce3 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 17:41:40 +0200 Subject: [PATCH 20/28] feat: Generate JavaDocs for attribute with and without methods --- .../org/fulib/templates/attributes.bean.stg | 18 ++++++++++++++++++ .../org/fulib/templates/attributes.javafx.stg | 6 ++++++ .../org/fulib/templates/attributes.pojo.stg | 18 ++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/src/main/resources/org/fulib/templates/attributes.bean.stg b/src/main/resources/org/fulib/templates/attributes.bean.stg index 626b7649..b35131d7 100644 --- a/src/main/resources/org/fulib/templates/attributes.bean.stg +++ b/src/main/resources/org/fulib/templates/attributes.bean.stg @@ -23,6 +23,9 @@ attrSet(attr) ::= << // --------------- With --------------- attrWithItem(attr) ::= << + + + public with( value) { if (this. == null) @@ -38,6 +41,9 @@ attrWithItem(attr) ::= << >> attrWithArray(attr) ::= << + + + public with(... value) { for (final item : value) @@ -49,6 +55,9 @@ attrWithArray(attr) ::= << >> attrWithColl(attr) ::= << + + + public with(import(java.util.Collection)\\> value) { for (final item : value) @@ -62,6 +71,9 @@ attrWithColl(attr) ::= << // --------------- Without --------------- attrWithoutItem(attr) ::= << + + + public without( value) { if (this. != null && this..removeAll(import(java.util.Collections).singleton(value))) @@ -73,6 +85,9 @@ attrWithoutItem(attr) ::= << >> attrWithoutArray(attr) ::= << + + + public without(... value) { for (final item : value) @@ -84,6 +99,9 @@ attrWithoutArray(attr) ::= << >> attrWithoutColl(attr) ::= << + + + public without(import(java.util.Collection)\\> value) { for (final item : value) diff --git a/src/main/resources/org/fulib/templates/attributes.javafx.stg b/src/main/resources/org/fulib/templates/attributes.javafx.stg index b88ea82d..e8f4983b 100644 --- a/src/main/resources/org/fulib/templates/attributes.javafx.stg +++ b/src/main/resources/org/fulib/templates/attributes.javafx.stg @@ -62,6 +62,9 @@ propertyGet(attr) ::= << >> attrWithItem(attr) ::= << + + + public with( value) { this..add(value); @@ -70,6 +73,9 @@ attrWithItem(attr) ::= << >> attrWithoutItem(attr) ::= << + + + public without( value) { this..removeAll(value); diff --git a/src/main/resources/org/fulib/templates/attributes.pojo.stg b/src/main/resources/org/fulib/templates/attributes.pojo.stg index 63592d47..b84b8871 100644 --- a/src/main/resources/org/fulib/templates/attributes.pojo.stg +++ b/src/main/resources/org/fulib/templates/attributes.pojo.stg @@ -105,6 +105,9 @@ attrSet(attr) ::= << // --------------- With --------------- attrWithItem(attr) ::= << + + + public with( value) { if (this. == null) @@ -117,6 +120,9 @@ attrWithItem(attr) ::= << >> attrWithArray(attr) ::= << + + + public with(... value) { this.with(import(java.util.Arrays).asList(value)); @@ -125,6 +131,9 @@ attrWithArray(attr) ::= << >> attrWithColl(attr) ::= << + + + public with(import(java.util.Collection)\\> value) { if (this. == null) @@ -142,6 +151,9 @@ attrWithColl(attr) ::= << // --------------- Without --------------- attrWithoutItem(attr) ::= << + + + public without( value) { this..removeAll(import(java.util.Collections).singleton(value)); @@ -150,6 +162,9 @@ attrWithoutItem(attr) ::= << >> attrWithoutArray(attr) ::= << + + + public without(... value) { this.without(import(java.util.Arrays).asList(value)); @@ -158,6 +173,9 @@ attrWithoutArray(attr) ::= << >> attrWithoutColl(attr) ::= << + + + public without(import(java.util.Collection)\\> value) { if (this. != null) From 826925b056cddbe7d9068927ff187092e37e2b8e Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 17:42:23 +0200 Subject: [PATCH 21/28] feat: Add description for Clazz.imports --- .../java/org/fulib/classmodel/GenModel.java | 8 +- src/main/java/org/fulib/classmodel/Clazz.java | 74 +++++++++++++++++-- .../java/org/fulib/classmodel/classModel.yaml | 5 ++ 3 files changed, 79 insertions(+), 8 deletions(-) diff --git a/src/gen/java/org/fulib/classmodel/GenModel.java b/src/gen/java/org/fulib/classmodel/GenModel.java index 7981bd7d..97ce1cb9 100644 --- a/src/gen/java/org/fulib/classmodel/GenModel.java +++ b/src/gen/java/org/fulib/classmodel/GenModel.java @@ -33,7 +33,13 @@ public void decorate(ClassModelManager mb) c .attribute("modified", BOOLEAN) .setDescription("a boolean indicating whether this attribute was modified. For internal use only."); - c.attribute("imports", STRING).setCollectionType(CollectionType.LinkedHashSet); + c + .attribute("imports", STRING) + .setCollectionType(CollectionType.LinkedHashSet) + .setDescription("the set of imported members.\n" + + "Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar},\n" + + "{@code import org.example.Foo;} or {@code import static org.example.Foo.bar;") + .setSince("1.2"); }); final Clazz Attribute = mb.haveClass("Attribute", c -> { diff --git a/src/main/java/org/fulib/classmodel/Clazz.java b/src/main/java/org/fulib/classmodel/Clazz.java index b0101aad..e6a936ad 100644 --- a/src/main/java/org/fulib/classmodel/Clazz.java +++ b/src/main/java/org/fulib/classmodel/Clazz.java @@ -694,13 +694,28 @@ public Clazz setImportList(LinkedHashSet value) return this; } - /** @since 1.2 */ + /** + * @return the set of imported members. + * Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}, + * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar; + * + * @since 1.2 + */ public Set getImports() { return this.imports != null ? Collections.unmodifiableSet(this.imports) : Collections.emptySet(); } - /** @since 1.2 */ + /** + * @param value + * the set of imported members. + * Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}, + * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar; + * + * @return this + * + * @since 1.2 + */ public Clazz withImports(String value) { if (this.imports == null) @@ -714,7 +729,16 @@ public Clazz withImports(String value) return this; } - /** @since 1.2 */ + /** + * @param value + * the set of imported members. + * Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}, + * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar; + * + * @return this + * + * @since 1.2 + */ public Clazz withImports(String... value) { for (final String item : value) @@ -724,7 +748,16 @@ public Clazz withImports(String... value) return this; } - /** @since 1.2 */ + /** + * @param value + * the set of imported members. + * Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}, + * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar; + * + * @return this + * + * @since 1.2 + */ public Clazz withImports(Collection value) { for (final String item : value) @@ -734,7 +767,16 @@ public Clazz withImports(Collection value) return this; } - /** @since 1.2 */ + /** + * @param value + * the set of imported members. + * Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}, + * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar; + * + * @return this + * + * @since 1.2 + */ public Clazz withoutImports(String value) { if (this.imports != null && this.imports.removeAll(Collections.singleton(value))) @@ -744,7 +786,16 @@ public Clazz withoutImports(String value) return this; } - /** @since 1.2 */ + /** + * @param value + * the set of imported members. + * Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}, + * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar; + * + * @return this + * + * @since 1.2 + */ public Clazz withoutImports(String... value) { for (final String item : value) @@ -754,7 +805,16 @@ public Clazz withoutImports(String... value) return this; } - /** @since 1.2 */ + /** + * @param value + * the set of imported members. + * Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}, + * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar; + * + * @return this + * + * @since 1.2 + */ public Clazz withoutImports(Collection value) { for (final String item : value) diff --git a/src/main/java/org/fulib/classmodel/classModel.yaml b/src/main/java/org/fulib/classmodel/classModel.yaml index 96aa8a31..33e04fcf 100644 --- a/src/main/java/org/fulib/classmodel/classModel.yaml +++ b/src/main/java/org/fulib/classmodel/classModel.yaml @@ -176,10 +176,15 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar - clazz_imports: Attribute clazz: clazz collectionType: c3 + description: "the set of imported members. +Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}, +{@code import org.example.Foo;} or {@code import static org.example.Foo.bar;" + descriptionLines: "the set of imported members." "Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}," "{@code import org.example.Foo;} or {@code import static org.example.Foo.bar;" id: Clazz_imports modified: false name: imports propertyStyle: Bean + since: 1.2 type: String typeSignature: String From 400aa64dd0db9fee01b0a052da01e35dae5f7500 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 17:46:30 +0200 Subject: [PATCH 22/28] feat: Add AssocRole.description and .since properties --- .../java/org/fulib/classmodel/GenModel.java | 8 +++ .../java/org/fulib/classmodel/AssocRole.java | 70 +++++++++++++++++++ .../java/org/fulib/classmodel/classModel.yaml | 26 ++++++- 3 files changed, 103 insertions(+), 1 deletion(-) diff --git a/src/gen/java/org/fulib/classmodel/GenModel.java b/src/gen/java/org/fulib/classmodel/GenModel.java index 97ce1cb9..90b158f5 100644 --- a/src/gen/java/org/fulib/classmodel/GenModel.java +++ b/src/gen/java/org/fulib/classmodel/GenModel.java @@ -77,6 +77,14 @@ public void decorate(ClassModelManager mb) .attribute("propertyStyle", STRING) .setDescription("the property style.\n" + "Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} are supported."); + c + .attribute("description", STRING) + .setDescription("the description of this role, used for generating JavaDocs") + .setSince("1.3"); + c + .attribute("since", STRING) + .setDescription("the version when this role was introduced, used for generating JavaDocs") + .setSince("1.3"); c .attribute("modified", BOOLEAN) .setDescription("a boolean indicating whether this role was modified. For internal use only."); diff --git a/src/main/java/org/fulib/classmodel/AssocRole.java b/src/main/java/org/fulib/classmodel/AssocRole.java index a7b51401..f4a676fd 100644 --- a/src/main/java/org/fulib/classmodel/AssocRole.java +++ b/src/main/java/org/fulib/classmodel/AssocRole.java @@ -22,6 +22,10 @@ public class AssocRole public static final String PROPERTY_modified = "modified"; public static final String PROPERTY_clazz = "clazz"; public static final String PROPERTY_other = "other"; + /** @since 1.3 */ + public static final String PROPERTY_description = "description"; + /** @since 1.3 */ + public static final String PROPERTY_since = "since"; // =============== Fields =============== @@ -34,6 +38,8 @@ public class AssocRole private CollectionType collectionType; private boolean aggregation; private String propertyStyle; + private String description; + private String since; private boolean modified; // =============== Properties =============== @@ -275,6 +281,68 @@ public AssocRole setPropertyStyle(String value) return this; } + /** + * @return the description of this role, used for generating JavaDocs + * + * @since 1.3 + */ + public String getDescription() + { + return this.description; + } + + /** + * @param value + * the description of this role, used for generating JavaDocs + * + * @return this + * + * @since 1.3 + */ + public AssocRole setDescription(String value) + { + if (Objects.equals(value, this.description)) + { + return this; + } + + final String oldValue = this.description; + this.description = value; + this.firePropertyChange(PROPERTY_description, oldValue, value); + return this; + } + + /** + * @return the version when this role was introduced, used for generating JavaDocs + * + * @since 1.3 + */ + public String getSince() + { + return this.since; + } + + /** + * @param value + * the version when this role was introduced, used for generating JavaDocs + * + * @return this + * + * @since 1.3 + */ + public AssocRole setSince(String value) + { + if (Objects.equals(value, this.since)) + { + return this; + } + + final String oldValue = this.since; + this.since = value; + this.firePropertyChange(PROPERTY_since, oldValue, value); + return this; + } + /** * @return a boolean indicating whether this role was modified. For internal use only. */ @@ -375,6 +443,8 @@ public String toString() final StringBuilder result = new StringBuilder(); result.append(' ').append(this.getName()); result.append(' ').append(this.getPropertyStyle()); + result.append(' ').append(this.getDescription()); + result.append(' ').append(this.getSince()); return result.substring(1); } } diff --git a/src/main/java/org/fulib/classmodel/classModel.yaml b/src/main/java/org/fulib/classmodel/classModel.yaml index 33e04fcf..bf7cb43f 100644 --- a/src/main/java/org/fulib/classmodel/classModel.yaml +++ b/src/main/java/org/fulib/classmodel/classModel.yaml @@ -32,7 +32,7 @@ roles: attribute_clazz - assocRole: Clazz - attributes: assocRole_name assocRole_cardinality assocRole_collectionType assocRole_aggregation assocRole_propertyStyle assocRole_modified + attributes: assocRole_name assocRole_cardinality assocRole_collectionType assocRole_aggregation assocRole_propertyStyle assocRole_modified assocRole_description assocRole_since model: c modified: false name: AssocRole @@ -424,6 +424,30 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar type: boolean typeSignature: boolean +- assocRole_description: Attribute + clazz: assocRole + description: "the description of this role, used for generating JavaDocs" + descriptionLines: "the description of this role, used for generating JavaDocs" + id: AssocRole_description + modified: false + name: description + propertyStyle: Bean + since: 1.3 + type: String + typeSignature: String + +- assocRole_since: Attribute + clazz: assocRole + description: "the version when this role was introduced, used for generating JavaDocs" + descriptionLines: "the version when this role was introduced, used for generating JavaDocs" + id: AssocRole_since + modified: false + name: since + propertyStyle: Bean + since: 1.3 + type: String + typeSignature: String + - assocRole_clazz: AssocRole aggregation: false cardinality: 1 From 0279aae8daa29cae46e2e799c48151512ebbe332 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 17:49:57 +0200 Subject: [PATCH 23/28] refactor: Add javadoc.stg --- .../org/fulib/templates/attributes.pojo.stg | 26 +------------------ .../resources/org/fulib/templates/javadoc.stg | 24 +++++++++++++++++ 2 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 src/main/resources/org/fulib/templates/javadoc.stg diff --git a/src/main/resources/org/fulib/templates/attributes.pojo.stg b/src/main/resources/org/fulib/templates/attributes.pojo.stg index b84b8871..b7f23374 100644 --- a/src/main/resources/org/fulib/templates/attributes.pojo.stg +++ b/src/main/resources/org/fulib/templates/attributes.pojo.stg @@ -1,4 +1,5 @@ import "java.dicts.stg" +import "javadoc.stg" collectionImpl(attr) ::= <% @@ -50,31 +51,6 @@ propertyDecl(attr) ::= << public static final String PROPERTY_ = ""; >> -// --------------- JavaDocs --------------- - -getterJavaDoc(attr) ::= << -/** - * @return - - * - * @since - - */ ->> - -setterJavaDoc(attr) ::= << -/** - * @param value - * - * - * @return this - - * - * @since - - */ ->> - // --------------- Simple Accessors --------------- attrGet(attr) ::= << diff --git a/src/main/resources/org/fulib/templates/javadoc.stg b/src/main/resources/org/fulib/templates/javadoc.stg new file mode 100644 index 00000000..c1760cbf --- /dev/null +++ b/src/main/resources/org/fulib/templates/javadoc.stg @@ -0,0 +1,24 @@ +// --------------- JavaDocs --------------- + +getterJavaDoc(attr) ::= << +/** + * @return + + * + * @since + + */ +>> + +setterJavaDoc(attr) ::= << +/** + * @param value + * + * + * @return this + + * + * @since + + */ +>> From 450989ba9cc3961576444f226618354ec7419e95 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 2 Sep 2020 17:56:39 +0200 Subject: [PATCH 24/28] feat: Implement description and since for roles --- .../org/fulib/templates/associations.bean.stg | 9 ++++++ .../fulib/templates/associations.javafx.stg | 15 ++++++++++ .../org/fulib/templates/associations.pojo.stg | 28 +++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/src/main/resources/org/fulib/templates/associations.bean.stg b/src/main/resources/org/fulib/templates/associations.bean.stg index 8b5b7728..56532b23 100644 --- a/src/main/resources/org/fulib/templates/associations.bean.stg +++ b/src/main/resources/org/fulib/templates/associations.bean.stg @@ -3,6 +3,9 @@ import "associations.pojo.stg" // --------------- Simple Accessors --------------- setMethod(role, other) ::= << + + + public set( value) { if (this. == value) @@ -33,6 +36,9 @@ setMethod(role, other) ::= << // --------------- With --------------- withItem(role, other) ::= << + + + public with( value) { if (this. == null) @@ -54,6 +60,9 @@ withItem(role, other) ::= << // --------------- Without --------------- withoutItem(role, other) ::= << + + + public without( value) { if (this. != null && this..remove(value)) diff --git a/src/main/resources/org/fulib/templates/associations.javafx.stg b/src/main/resources/org/fulib/templates/associations.javafx.stg index 24edcf8e..78a610cd 100644 --- a/src/main/resources/org/fulib/templates/associations.javafx.stg +++ b/src/main/resources/org/fulib/templates/associations.javafx.stg @@ -15,6 +15,9 @@ roleAttrDecl(role, other) ::= << >> getMethod(role, other) ::= << + + + public import(javafx.beans.property.SimpleListProperty)\<\> get() { @@ -28,6 +31,9 @@ getMethod(role, other) ::= << >> setMethod(role, other) ::= << + + + public set( value) { if (value != this..getValue()) @@ -39,6 +45,9 @@ setMethod(role, other) ::= << >> withItem(role, other) ::= << + + + public with( value) { if (!this..contains(value)) @@ -50,6 +59,9 @@ withItem(role, other) ::= << >> withoutItem(role, other) ::= << + + + public without( value) { this..remove(value); @@ -60,6 +72,9 @@ withoutItem(role, other) ::= << // --------------- Additional Templates --------------- propertyMethod(role, other) ::= << + + + public import(javafx.beans.property.ObjectProperty)\<\> Property() { return this.; diff --git a/src/main/resources/org/fulib/templates/associations.pojo.stg b/src/main/resources/org/fulib/templates/associations.pojo.stg index 6c049c72..674d5413 100644 --- a/src/main/resources/org/fulib/templates/associations.pojo.stg +++ b/src/main/resources/org/fulib/templates/associations.pojo.stg @@ -1,4 +1,5 @@ import "java.dicts.stg" +import "javadoc.stg" collectionImpl(role, other) ::= <% @@ -46,12 +47,18 @@ roleAttrDecl(role, other) ::= << >> propertyDecl(role, other) ::= << + + /** @since */ + public static final String PROPERTY_ = ""; >> // --------------- Simple Accessors --------------- getMethod(role, other) ::= << + + + public get() { @@ -63,6 +70,9 @@ getMethod(role, other) ::= << >> setMethod(role, other) ::= << + + + public set( value) { if (this. == value) @@ -92,6 +102,9 @@ setMethod(role, other) ::= << // --------------- With --------------- withItem(role, other) ::= << + + + public with( value) { if (this. == null) @@ -110,6 +123,9 @@ withItem(role, other) ::= << >> withArray(role, other) ::= << + + + public with(... value) { for (final item : value) @@ -121,6 +137,9 @@ withArray(role, other) ::= << >> withColl(role, other) ::= << + + + public with(import(java.util.Collection)\\> value) { for (final item : value) @@ -134,6 +153,9 @@ withColl(role, other) ::= << // --------------- Without --------------- withoutItem(role, other) ::= << + + + public without( value) { if (this. != null && this..remove(value)) @@ -147,6 +169,9 @@ withoutItem(role, other) ::= << >> withoutArray(role, other) ::= << + + + public without(... value) { for (final item : value) @@ -158,6 +183,9 @@ withoutArray(role, other) ::= << >> withoutColl(role, other) ::= << + + + public without(import(java.util.Collection)\\> value) { for (final item : value) From 44cb832c11202e7895f7498d0b1bb21a046483bd Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Thu, 10 Sep 2020 14:36:08 +0200 Subject: [PATCH 25/28] fix: Add AssocRole.getDescriptionLines --- .../java/org/fulib/classmodel/AssocRole.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/org/fulib/classmodel/AssocRole.java b/src/main/java/org/fulib/classmodel/AssocRole.java index f4a676fd..32816928 100644 --- a/src/main/java/org/fulib/classmodel/AssocRole.java +++ b/src/main/java/org/fulib/classmodel/AssocRole.java @@ -4,6 +4,9 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import java.util.Objects; public class AssocRole @@ -312,6 +315,19 @@ public AssocRole setDescription(String value) return this; } + /** + * @return the lines of the description of this attribute, used for generating JavaDocs + * + * @since 1.3 + * + * @deprecated for internal use only + */ + @Deprecated + public List getDescriptionLines() + { + return this.getDescription() == null ? Collections.emptyList() : Arrays.asList(this.getDescription().split("\n")); + } + /** * @return the version when this role was introduced, used for generating JavaDocs * From ea3f9cd0a1405097d47a5c358b580699e83e8fe5 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Thu, 10 Sep 2020 14:37:39 +0200 Subject: [PATCH 26/28] fix: Update generated model classes --- .../java/org/fulib/classmodel/GenModel.java | 16 +- .../java/org/fulib/classmodel/ClassModel.java | 56 ++++- src/main/java/org/fulib/classmodel/Clazz.java | 226 +++++++++++++++--- .../java/org/fulib/classmodel/classModel.yaml | 61 +++-- 4 files changed, 295 insertions(+), 64 deletions(-) diff --git a/src/gen/java/org/fulib/classmodel/GenModel.java b/src/gen/java/org/fulib/classmodel/GenModel.java index 90b158f5..af12306b 100644 --- a/src/gen/java/org/fulib/classmodel/GenModel.java +++ b/src/gen/java/org/fulib/classmodel/GenModel.java @@ -102,15 +102,21 @@ public void decorate(ClassModelManager mb) c.attribute("annotations", STRING); }); - mb.associate(ClassModel, "classes", MANY, Clazz, "model", ONE); + mb + .associate(ClassModel, "classes", MANY, Clazz, "model", ONE) + .setDescription("the classes contained in this model") + .setSince("1.2"); - mb.associate(Clazz, "attributes", MANY, Attribute, "clazz", ONE); + mb.associate(Clazz, "attributes", MANY, Attribute, "clazz", ONE).setDescription("the attributes").setSince("1.2"); - mb.associate(Clazz, "roles", MANY, AssocRole, "clazz", ONE); + mb.associate(Clazz, "roles", MANY, AssocRole, "clazz", ONE).setDescription("the roles").setSince("1.2"); - mb.associate(Clazz, "methods", MANY, FMethod, "clazz", ONE); + mb.associate(Clazz, "methods", MANY, FMethod, "clazz", ONE).setDescription("the methods").setSince("1.2"); - mb.associate(Clazz, "superClass", ONE, Clazz, "subClasses", MANY); + mb + .associate(Clazz, "subClasses", MANY, Clazz, "superClass", ONE) + .setDescription("the subclasses") + .setSince("1.2"); mb.associate(AssocRole, "other", ONE, AssocRole, "other", ONE); diff --git a/src/main/java/org/fulib/classmodel/ClassModel.java b/src/main/java/org/fulib/classmodel/ClassModel.java index 78f09bc2..150e1bcb 100644 --- a/src/main/java/org/fulib/classmodel/ClassModel.java +++ b/src/main/java/org/fulib/classmodel/ClassModel.java @@ -27,7 +27,7 @@ public class ClassModel /** @since 1.2 */ public static final String PROPERTY_defaultCollectionType = "defaultCollectionType"; public static final String PROPERTY_defaultPropertyStyle = "defaultPropertyStyle"; - public static final String PROPERTY_classes = "classes"; + public static final String PROPERTY_classes = "classes" /* no fulib */; // =============== Fields =============== @@ -217,7 +217,14 @@ else if (item instanceof Clazz) return this; } - /** @since 1.2 */ + /** + * @param value + * the classes contained in this model + * + * @return this + * + * @since 1.2 + */ public ClassModel withClasses(Clazz value) { if (this.classes == null) @@ -233,7 +240,14 @@ public ClassModel withClasses(Clazz value) return this; } - /** @since 1.2 */ + /** + * @param value + * the classes contained in this model + * + * @return this + * + * @since 1.2 + */ public ClassModel withClasses(Clazz... value) { for (final Clazz item : value) @@ -243,7 +257,14 @@ public ClassModel withClasses(Clazz... value) return this; } - /** @since 1.2 */ + /** + * @param value + * the classes contained in this model + * + * @return this + * + * @since 1.2 + */ public ClassModel withClasses(Collection value) { for (final Clazz item : value) @@ -279,7 +300,14 @@ else if (item instanceof Clazz) return this; } - /** @since 1.2 */ + /** + * @param value + * the classes contained in this model + * + * @return this + * + * @since 1.2 + */ public ClassModel withoutClasses(Clazz value) { if (this.classes != null && this.classes.remove(value)) @@ -290,7 +318,14 @@ public ClassModel withoutClasses(Clazz value) return this; } - /** @since 1.2 */ + /** + * @param value + * the classes contained in this model + * + * @return this + * + * @since 1.2 + */ public ClassModel withoutClasses(Clazz... value) { for (final Clazz item : value) @@ -300,7 +335,14 @@ public ClassModel withoutClasses(Clazz... value) return this; } - /** @since 1.2 */ + /** + * @param value + * the classes contained in this model + * + * @return this + * + * @since 1.2 + */ public ClassModel withoutClasses(Collection value) { for (final Clazz item : value) diff --git a/src/main/java/org/fulib/classmodel/Clazz.java b/src/main/java/org/fulib/classmodel/Clazz.java index e6a936ad..0794c4ec 100644 --- a/src/main/java/org/fulib/classmodel/Clazz.java +++ b/src/main/java/org/fulib/classmodel/Clazz.java @@ -38,11 +38,11 @@ public class Clazz public static final String PROPERTY_propertyStyle = "propertyStyle"; public static final String PROPERTY_modified = "modified"; public static final String PROPERTY_model = "model"; - public static final String PROPERTY_attributes = "attributes"; - public static final String PROPERTY_roles = "roles"; + public static final String PROPERTY_attributes = "attributes" /* no fulib */; + public static final String PROPERTY_roles = "roles" /* no fulib */; public static final String PROPERTY_superClass = "superClass"; - public static final String PROPERTY_subClasses = "subClasses"; - public static final String PROPERTY_methods = "methods"; + public static final String PROPERTY_subClasses = "subClasses" /* no fulib */; + public static final String PROPERTY_methods = "methods" /* no fulib */; /** @since 1.2 */ public static final String PROPERTY_imports = "imports"; /** @deprecated since 1.2; use {@link #PROPERTY_imports} instead */ @@ -178,7 +178,14 @@ else if (item instanceof Clazz) return this; } - /** @since 1.2 */ + /** + * @param value + * the subclasses + * + * @return this + * + * @since 1.2 + */ public Clazz withSubClasses(Clazz value) { if (this.subClasses == null) @@ -194,7 +201,14 @@ public Clazz withSubClasses(Clazz value) return this; } - /** @since 1.2 */ + /** + * @param value + * the subclasses + * + * @return this + * + * @since 1.2 + */ public Clazz withSubClasses(Clazz... value) { for (final Clazz item : value) @@ -204,7 +218,14 @@ public Clazz withSubClasses(Clazz... value) return this; } - /** @since 1.2 */ + /** + * @param value + * the subclasses + * + * @return this + * + * @since 1.2 + */ public Clazz withSubClasses(Collection value) { for (final Clazz item : value) @@ -240,7 +261,14 @@ else if (item instanceof Clazz) return this; } - /** @since 1.2 */ + /** + * @param value + * the subclasses + * + * @return this + * + * @since 1.2 + */ public Clazz withoutSubClasses(Clazz value) { if (this.subClasses != null && this.subClasses.remove(value)) @@ -251,7 +279,14 @@ public Clazz withoutSubClasses(Clazz value) return this; } - /** @since 1.2 */ + /** + * @param value + * the subclasses + * + * @return this + * + * @since 1.2 + */ public Clazz withoutSubClasses(Clazz... value) { for (final Clazz item : value) @@ -261,7 +296,14 @@ public Clazz withoutSubClasses(Clazz... value) return this; } - /** @since 1.2 */ + /** + * @param value + * the subclasses + * + * @return this + * + * @since 1.2 + */ public Clazz withoutSubClasses(Collection value) { for (final Clazz item : value) @@ -318,7 +360,14 @@ else if (item instanceof Attribute) return this; } - /** @since 1.2 */ + /** + * @param value + * the attributes + * + * @return this + * + * @since 1.2 + */ public Clazz withAttributes(Attribute value) { if (this.attributes == null) @@ -334,7 +383,14 @@ public Clazz withAttributes(Attribute value) return this; } - /** @since 1.2 */ + /** + * @param value + * the attributes + * + * @return this + * + * @since 1.2 + */ public Clazz withAttributes(Attribute... value) { for (final Attribute item : value) @@ -344,7 +400,14 @@ public Clazz withAttributes(Attribute... value) return this; } - /** @since 1.2 */ + /** + * @param value + * the attributes + * + * @return this + * + * @since 1.2 + */ public Clazz withAttributes(Collection value) { for (final Attribute item : value) @@ -380,7 +443,14 @@ else if (item instanceof Attribute) return this; } - /** @since 1.2 */ + /** + * @param value + * the attributes + * + * @return this + * + * @since 1.2 + */ public Clazz withoutAttributes(Attribute value) { if (this.attributes != null && this.attributes.remove(value)) @@ -391,7 +461,14 @@ public Clazz withoutAttributes(Attribute value) return this; } - /** @since 1.2 */ + /** + * @param value + * the attributes + * + * @return this + * + * @since 1.2 + */ public Clazz withoutAttributes(Attribute... value) { for (final Attribute item : value) @@ -401,7 +478,14 @@ public Clazz withoutAttributes(Attribute... value) return this; } - /** @since 1.2 */ + /** + * @param value + * the attributes + * + * @return this + * + * @since 1.2 + */ public Clazz withoutAttributes(Collection value) { for (final Attribute item : value) @@ -458,7 +542,14 @@ else if (item instanceof AssocRole) return this; } - /** @since 1.2 */ + /** + * @param value + * the roles + * + * @return this + * + * @since 1.2 + */ public Clazz withRoles(AssocRole value) { if (this.roles == null) @@ -474,7 +565,14 @@ public Clazz withRoles(AssocRole value) return this; } - /** @since 1.2 */ + /** + * @param value + * the roles + * + * @return this + * + * @since 1.2 + */ public Clazz withRoles(AssocRole... value) { for (final AssocRole item : value) @@ -484,7 +582,14 @@ public Clazz withRoles(AssocRole... value) return this; } - /** @since 1.2 */ + /** + * @param value + * the roles + * + * @return this + * + * @since 1.2 + */ public Clazz withRoles(Collection value) { for (final AssocRole item : value) @@ -520,7 +625,14 @@ else if (item instanceof AssocRole) return this; } - /** @since 1.2 */ + /** + * @param value + * the roles + * + * @return this + * + * @since 1.2 + */ public Clazz withoutRoles(AssocRole value) { if (this.roles != null && this.roles.remove(value)) @@ -531,7 +643,14 @@ public Clazz withoutRoles(AssocRole value) return this; } - /** @since 1.2 */ + /** + * @param value + * the roles + * + * @return this + * + * @since 1.2 + */ public Clazz withoutRoles(AssocRole... value) { for (final AssocRole item : value) @@ -541,7 +660,14 @@ public Clazz withoutRoles(AssocRole... value) return this; } - /** @since 1.2 */ + /** + * @param value + * the roles + * + * @return this + * + * @since 1.2 + */ public Clazz withoutRoles(Collection value) { for (final AssocRole item : value) @@ -586,7 +712,14 @@ else if (item instanceof FMethod) return this; } - /** @since 1.2 */ + /** + * @param value + * the methods + * + * @return this + * + * @since 1.2 + */ public Clazz withMethods(FMethod value) { if (this.methods == null) @@ -602,7 +735,14 @@ public Clazz withMethods(FMethod value) return this; } - /** @since 1.2 */ + /** + * @param value + * the methods + * + * @return this + * + * @since 1.2 + */ public Clazz withMethods(FMethod... value) { for (final FMethod item : value) @@ -612,7 +752,14 @@ public Clazz withMethods(FMethod... value) return this; } - /** @since 1.2 */ + /** + * @param value + * the methods + * + * @return this + * + * @since 1.2 + */ public Clazz withMethods(Collection value) { for (final FMethod item : value) @@ -648,7 +795,14 @@ else if (item instanceof FMethod) return this; } - /** @since 1.2 */ + /** + * @param value + * the methods + * + * @return this + * + * @since 1.2 + */ public Clazz withoutMethods(FMethod value) { if (this.methods != null && this.methods.remove(value)) @@ -659,7 +813,14 @@ public Clazz withoutMethods(FMethod value) return this; } - /** @since 1.2 */ + /** + * @param value + * the methods + * + * @return this + * + * @since 1.2 + */ public Clazz withoutMethods(FMethod... value) { for (final FMethod item : value) @@ -669,7 +830,14 @@ public Clazz withoutMethods(FMethod... value) return this; } - /** @since 1.2 */ + /** + * @param value + * the methods + * + * @return this + * + * @since 1.2 + */ public Clazz withoutMethods(Collection value) { for (final FMethod item : value) @@ -941,8 +1109,8 @@ public void removeYou() this.withoutAttributes(new ArrayList<>(this.getAttributes())); this.withoutRoles(new ArrayList<>(this.getRoles())); this.withoutMethods(new ArrayList<>(this.getMethods())); - this.setSuperClass(null); this.withoutSubClasses(new ArrayList<>(this.getSubClasses())); + this.setSuperClass(null); } @Override diff --git a/src/main/java/org/fulib/classmodel/classModel.yaml b/src/main/java/org/fulib/classmodel/classModel.yaml index bf7cb43f..5b38484f 100644 --- a/src/main/java/org/fulib/classmodel/classModel.yaml +++ b/src/main/java/org/fulib/classmodel/classModel.yaml @@ -21,7 +21,7 @@ modified: false name: Clazz propertyStyle: Bean - roles: clazz_model clazz_attributes clazz_roles clazz_methods clazz_superClass clazz_subClasses + roles: clazz_model clazz_attributes clazz_roles clazz_methods clazz_subClasses clazz_superClass - attribute: Clazz attributes: attribute_name attribute_type attribute_collectionType attribute_initialization attribute_propertyStyle attribute_modified attribute_description attribute_since @@ -32,7 +32,7 @@ roles: attribute_clazz - assocRole: Clazz - attributes: assocRole_name assocRole_cardinality assocRole_collectionType assocRole_aggregation assocRole_propertyStyle assocRole_modified assocRole_description assocRole_since + attributes: assocRole_name assocRole_cardinality assocRole_collectionType assocRole_aggregation assocRole_propertyStyle assocRole_description assocRole_since assocRole_modified model: c modified: false name: AssocRole @@ -134,12 +134,15 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar cardinality: 42 clazz: classModel collectionType: c1 + description: "the classes contained in this model" + descriptionLines: "the classes contained in this model" id: ClassModel_classes modified: false name: classes other: clazz_model propertyStyle: Bean roleType: "java.util.ArrayList<%s>" + since: 1.2 - clazz_name: Attribute clazz: clazz @@ -205,58 +208,70 @@ Elements can have one of the formats {@code org.example.Foo}, {@code static org. cardinality: 42 clazz: clazz collectionType: c1 + description: "the attributes" + descriptionLines: "the attributes" id: Clazz_attributes modified: false name: attributes other: attribute_clazz propertyStyle: Bean roleType: "java.util.ArrayList<%s>" + since: 1.2 - clazz_roles: AssocRole aggregation: false cardinality: 42 clazz: clazz collectionType: c1 + description: "the roles" + descriptionLines: "the roles" id: Clazz_roles modified: false name: roles other: assocRole_clazz propertyStyle: Bean roleType: "java.util.ArrayList<%s>" + since: 1.2 - clazz_methods: AssocRole aggregation: false cardinality: 42 clazz: clazz collectionType: c1 + description: "the methods" + descriptionLines: "the methods" id: Clazz_methods modified: false name: methods other: fMethod_clazz propertyStyle: Bean roleType: "java.util.ArrayList<%s>" + since: 1.2 -- clazz_superClass: AssocRole +- clazz_subClasses: AssocRole aggregation: false - cardinality: 1 + cardinality: 42 clazz: clazz collectionType: c1 - id: Clazz_superClass + description: "the subclasses" + descriptionLines: "the subclasses" + id: Clazz_subClasses modified: false - name: superClass - other: clazz_subClasses + name: subClasses + other: clazz_superClass propertyStyle: Bean roleType: "java.util.ArrayList<%s>" + since: 1.2 -- clazz_subClasses: AssocRole +- clazz_superClass: AssocRole aggregation: false - cardinality: 42 + cardinality: 1 clazz: clazz collectionType: c1 - id: Clazz_subClasses + id: Clazz_superClass modified: false - name: subClasses - other: clazz_superClass + name: superClass + other: clazz_subClasses propertyStyle: Bean roleType: "java.util.ArrayList<%s>" @@ -413,17 +428,6 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar type: String typeSignature: String -- assocRole_modified: Attribute - clazz: assocRole - description: "a boolean indicating whether this role was modified. For internal use only." - descriptionLines: "a boolean indicating whether this role was modified. For internal use only." - id: AssocRole_modified - modified: false - name: modified - propertyStyle: Bean - type: boolean - typeSignature: boolean - - assocRole_description: Attribute clazz: assocRole description: "the description of this role, used for generating JavaDocs" @@ -448,6 +452,17 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar type: String typeSignature: String +- assocRole_modified: Attribute + clazz: assocRole + description: "a boolean indicating whether this role was modified. For internal use only." + descriptionLines: "a boolean indicating whether this role was modified. For internal use only." + id: AssocRole_modified + modified: false + name: modified + propertyStyle: Bean + type: boolean + typeSignature: boolean + - assocRole_clazz: AssocRole aggregation: false cardinality: 1 From c8ea249b3d33b9f38ff83fe27b42076782b04a46 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Thu, 10 Sep 2020 14:40:31 +0200 Subject: [PATCH 27/28] fix: Add missing closing brace to Clazz.imports description --- src/gen/java/org/fulib/classmodel/GenModel.java | 2 +- src/main/java/org/fulib/classmodel/Clazz.java | 14 +++++++------- src/main/java/org/fulib/classmodel/classModel.yaml | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gen/java/org/fulib/classmodel/GenModel.java b/src/gen/java/org/fulib/classmodel/GenModel.java index af12306b..c927d330 100644 --- a/src/gen/java/org/fulib/classmodel/GenModel.java +++ b/src/gen/java/org/fulib/classmodel/GenModel.java @@ -38,7 +38,7 @@ public void decorate(ClassModelManager mb) .setCollectionType(CollectionType.LinkedHashSet) .setDescription("the set of imported members.\n" + "Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar},\n" - + "{@code import org.example.Foo;} or {@code import static org.example.Foo.bar;") + + "{@code import org.example.Foo;} or {@code import static org.example.Foo.bar;}") .setSince("1.2"); }); diff --git a/src/main/java/org/fulib/classmodel/Clazz.java b/src/main/java/org/fulib/classmodel/Clazz.java index 0794c4ec..c2dbfc6a 100644 --- a/src/main/java/org/fulib/classmodel/Clazz.java +++ b/src/main/java/org/fulib/classmodel/Clazz.java @@ -865,7 +865,7 @@ public Clazz setImportList(LinkedHashSet value) /** * @return the set of imported members. * Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}, - * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar; + * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar;} * * @since 1.2 */ @@ -878,7 +878,7 @@ public Set getImports() * @param value * the set of imported members. * Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}, - * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar; + * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar;} * * @return this * @@ -901,7 +901,7 @@ public Clazz withImports(String value) * @param value * the set of imported members. * Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}, - * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar; + * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar;} * * @return this * @@ -920,7 +920,7 @@ public Clazz withImports(String... value) * @param value * the set of imported members. * Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}, - * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar; + * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar;} * * @return this * @@ -939,7 +939,7 @@ public Clazz withImports(Collection value) * @param value * the set of imported members. * Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}, - * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar; + * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar;} * * @return this * @@ -958,7 +958,7 @@ public Clazz withoutImports(String value) * @param value * the set of imported members. * Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}, - * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar; + * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar;} * * @return this * @@ -977,7 +977,7 @@ public Clazz withoutImports(String... value) * @param value * the set of imported members. * Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}, - * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar; + * {@code import org.example.Foo;} or {@code import static org.example.Foo.bar;} * * @return this * diff --git a/src/main/java/org/fulib/classmodel/classModel.yaml b/src/main/java/org/fulib/classmodel/classModel.yaml index 5b38484f..f2e63376 100644 --- a/src/main/java/org/fulib/classmodel/classModel.yaml +++ b/src/main/java/org/fulib/classmodel/classModel.yaml @@ -181,8 +181,8 @@ Currently, only {@link Type#POJO}, {@link Type#BEAN} and {@link Type#JAVA_FX} ar collectionType: c3 description: "the set of imported members. Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}, -{@code import org.example.Foo;} or {@code import static org.example.Foo.bar;" - descriptionLines: "the set of imported members." "Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}," "{@code import org.example.Foo;} or {@code import static org.example.Foo.bar;" +{@code import org.example.Foo;} or {@code import static org.example.Foo.bar;}" + descriptionLines: "the set of imported members." "Elements can have one of the formats {@code org.example.Foo}, {@code static org.example.Foo.bar}," "{@code import org.example.Foo;} or {@code import static org.example.Foo.bar;}" id: Clazz_imports modified: false name: imports From 6b179b9ad21fdf8acab81450ddb0bc6e9021f69d Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Fri, 11 Sep 2020 10:33:59 +0200 Subject: [PATCH 28/28] fix: Deprecate Attribute.getDescriptionLines --- src/main/java/org/fulib/classmodel/AssocRole.java | 1 - src/main/java/org/fulib/classmodel/Attribute.java | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/fulib/classmodel/AssocRole.java b/src/main/java/org/fulib/classmodel/AssocRole.java index 32816928..dd2d919d 100644 --- a/src/main/java/org/fulib/classmodel/AssocRole.java +++ b/src/main/java/org/fulib/classmodel/AssocRole.java @@ -319,7 +319,6 @@ public AssocRole setDescription(String value) * @return the lines of the description of this attribute, used for generating JavaDocs * * @since 1.3 - * * @deprecated for internal use only */ @Deprecated diff --git a/src/main/java/org/fulib/classmodel/Attribute.java b/src/main/java/org/fulib/classmodel/Attribute.java index 4432a453..675bd7a8 100644 --- a/src/main/java/org/fulib/classmodel/Attribute.java +++ b/src/main/java/org/fulib/classmodel/Attribute.java @@ -278,7 +278,9 @@ public Attribute setDescription(String value) * @return the lines of the description of this attribute, used for generating JavaDocs * * @since 1.3 + * @deprecated for internal use only */ + @Deprecated public List getDescriptionLines() { return this.getDescription() == null ? Collections.emptyList() : Arrays.asList(this.getDescription().split("\n"));