From 7e02518026491acc40cf8f8deb36953affdb3dfc Mon Sep 17 00:00:00 2001
From: Gaurav Gupta
Date: Mon, 28 Oct 2024 17:19:07 +0530
Subject: [PATCH] FISH-9827 Fixes Javadoc error
---
starter-generator/pom.xml | 36 ++++-
.../starter/application/domain/Attribute.java | 135 ++++++++++++++++++
.../domain/AttributeSerializer.java | 9 +-
.../starter/application/util/Inflector.java | 30 ++--
.../application/util/StringHelper.java | 36 ++---
5 files changed, 212 insertions(+), 34 deletions(-)
diff --git a/starter-generator/pom.xml b/starter-generator/pom.xml
index 28aadca..96ea38f 100644
--- a/starter-generator/pom.xml
+++ b/starter-generator/pom.xml
@@ -29,11 +29,45 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.11.0
+ 3.13.0
17
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ 3.4.0
+
+ false
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 3.3.0
+
+
+ attach-sources
+
+ jar-no-fork
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 3.10.0
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
diff --git a/starter-generator/src/main/java/fish/payara/starter/application/domain/Attribute.java b/starter-generator/src/main/java/fish/payara/starter/application/domain/Attribute.java
index ef550d1..7746e17 100644
--- a/starter-generator/src/main/java/fish/payara/starter/application/domain/Attribute.java
+++ b/starter-generator/src/main/java/fish/payara/starter/application/domain/Attribute.java
@@ -42,108 +42,223 @@ public class Attribute {
private Boolean display;
private String htmlLabel;
+ /** Default constructor for Attribute. */
public Attribute() {
}
+ /**
+ * Constructor for Attribute with specified name, type, and primary key status.
+ *
+ * @param name the name of the attribute
+ * @param type the type of the attribute
+ * @param isPrimaryKey indicates if this attribute is a primary key
+ */
public Attribute(String name, String type, boolean isPrimaryKey) {
this.name = name;
this.type = type;
this.primaryKey = isPrimaryKey;
}
+ /**
+ * Constructor for Attribute with specified name, multi status, and relation type.
+ *
+ * @param name the name of the attribute
+ * @param multi indicates if the attribute can have multiple values
+ * @param relation the type of relation for the attribute
+ */
public Attribute(String name, boolean multi, String relation) {
this.name = name;
this.type = relation;
this.multi = multi;
}
+ /**
+ * Returns the name of the attribute.
+ *
+ * @return the name of the attribute
+ */
public String getName() {
return name;
}
+ /**
+ * Returns the name of the attribute in start case format.
+ *
+ * @return the start case name
+ */
@JsonbTransient
public String getStartCaseName() {
return startCase(name);
}
+ /**
+ * Returns the name of the attribute in lower case format.
+ *
+ * @return the lower case name
+ */
@JsonbTransient
public String getLowerCaseName() {
return name.toLowerCase();
}
+ /**
+ * Returns the name of the attribute in title case format.
+ *
+ * @return the title case name
+ */
@JsonbTransient
public String getTitleCaseName() {
return titleCase(name);
}
+ /**
+ * Returns the pluralized lower case name of the attribute.
+ *
+ * @return the pluralized lower case name
+ */
@JsonbTransient
public String getLowerCasePluralizeName() {
return pluralize(name.toLowerCase());
}
+ /**
+ * Returns the pluralized title case name of the attribute.
+ *
+ * @return the pluralized title case name
+ */
@JsonbTransient
public String getTitleCasePluralizeName() {
return pluralize(titleCase(name));
}
+ /**
+ * Returns the type of the attribute.
+ *
+ * @return the type of the attribute
+ */
public String getType() {
return type;
}
+ /**
+ * Checks if the attribute is a number type.
+ *
+ * @return true if the attribute type is a number, false otherwise
+ */
@JsonbTransient
public boolean isNumber() {
return AttributeType.isNumber(type);
}
+ /**
+ * Checks if this attribute is a primary key.
+ *
+ * @return true if this attribute is a primary key, false otherwise
+ */
public boolean isPrimaryKey() {
return primaryKey;
}
+ /**
+ * Checks if this attribute is required.
+ *
+ * @return true if this attribute is required, false otherwise
+ */
@JsonbTransient
public boolean isRequired() {
return required;
}
+ /**
+ * Sets whether this attribute is required.
+ *
+ * @param required true if this attribute is required, false otherwise
+ */
public void setRequired(boolean required) {
this.required = required;
}
+ /**
+ * Checks if this attribute can have multiple values.
+ *
+ * @return true if this attribute can have multiple values, false otherwise
+ */
public boolean isMulti() {
return multi;
}
+ /**
+ * Returns the tooltip text of the attribute.
+ *
+ * @return the tooltip text
+ */
@JsonbTransient
public String getToolTipText() {
return tooltip;
}
+ /**
+ * Checks if the attribute has a tooltip.
+ *
+ * @return true if the attribute has a tooltip, false otherwise
+ */
@JsonbTransient
public boolean isToolTip() {
return getToolTipText() != null && !getToolTipText().trim().isEmpty();
}
+ /**
+ * Sets the tooltip text for the attribute.
+ *
+ * @param tooltip the tooltip text to set
+ */
public void setTooltip(String tooltip) {
this.tooltip = tooltip;
}
+ /**
+ * Returns the HTML label associated with the attribute.
+ *
+ * @return the HTML label
+ */
@JsonbTransient
public String getHtmlLabel() {
return htmlLabel;
}
+ /**
+ * Sets the HTML label for the attribute.
+ *
+ * @param htmllabel the HTML label to set
+ */
public void setHtmlLabel(String htmllabel) {
this.htmlLabel = htmllabel;
}
+ /**
+ * Checks if this attribute should be displayed.
+ *
+ * @return true if the attribute is to be displayed, false otherwise
+ */
@JsonbTransient
public Boolean isDisplay() {
return display;
}
+ /**
+ * Sets the display status for the attribute.
+ *
+ * @param display true if the attribute should be displayed, false otherwise
+ */
public void setDisplay(Boolean display) {
this.display = display;
}
+ /**
+ * Returns a list of imports required for the attribute type.
+ *
+ * @return a list of import strings
+ */
@JsonbTransient
public List getImports() {
List _import = new ArrayList<>();
@@ -155,18 +270,38 @@ public List getImports() {
return _import;
}
+ /**
+ * Sets the name of the attribute.
+ *
+ * @param name the name to set
+ */
public void setName(String name) {
this.name = name;
}
+ /**
+ * Sets the type of the attribute.
+ *
+ * @param type the type to set
+ */
public void setType(String type) {
this.type = type;
}
+ /**
+ * Sets the primary key status for the attribute.
+ *
+ * @param isPrimaryKey true if this attribute is a primary key, false otherwise
+ */
public void setPrimaryKey(boolean isPrimaryKey) {
this.primaryKey = isPrimaryKey;
}
+ /**
+ * Sets whether this attribute can have multiple values.
+ *
+ * @param multi true if this attribute can have multiple values, false otherwise
+ */
public void setMulti(boolean multi) {
this.multi = multi;
}
diff --git a/starter-generator/src/main/java/fish/payara/starter/application/domain/AttributeSerializer.java b/starter-generator/src/main/java/fish/payara/starter/application/domain/AttributeSerializer.java
index 9491790..4aee5ee 100644
--- a/starter-generator/src/main/java/fish/payara/starter/application/domain/AttributeSerializer.java
+++ b/starter-generator/src/main/java/fish/payara/starter/application/domain/AttributeSerializer.java
@@ -42,13 +42,18 @@
import jakarta.json.bind.serializer.SerializationContext;
import jakarta.json.stream.JsonGenerator;
+/**
+ * A serializer for the {@link Attribute} class that defines how an
+ * Attribute object should be serialized to JSON.
+ * This class implements the {@link JsonbSerializer} interface
+ * to provide custom serialization logic for attributes.
+ */
public class AttributeSerializer implements JsonbSerializer {
@Override
public void serialize(Attribute attribute, JsonGenerator generator, SerializationContext ctx) {
generator.writeStartObject();
- // Always write the name and type
generator.write("name", attribute.getName());
generator.write("type", attribute.getType());
@@ -61,4 +66,4 @@ public void serialize(Attribute attribute, JsonGenerator generator, Serializatio
generator.writeEnd();
}
-}
\ No newline at end of file
+}
diff --git a/starter-generator/src/main/java/fish/payara/starter/application/util/Inflector.java b/starter-generator/src/main/java/fish/payara/starter/application/util/Inflector.java
index 34889b7..ac7b033 100644
--- a/starter-generator/src/main/java/fish/payara/starter/application/util/Inflector.java
+++ b/starter-generator/src/main/java/fish/payara/starter/application/util/Inflector.java
@@ -198,7 +198,8 @@ public String camelize(String word) {
* method also converts '/' characters to '::' because that reflects the
* normal syntax for fully qualified names in Ruby.
*
- *
+ *
+ * Inflector Rules
*
* Input |
* Output |
@@ -260,7 +261,8 @@ public String camelize(String word, boolean flag) {
* Create and return a simple class name that corresponds to a addPlural
* table name. Any leading schema name will be trimmed.
*
- *
+ *
+ * Inflector Rules
*
* Input |
* Output |
@@ -291,7 +293,8 @@ public String classify(String tableName) {
*
* Replace underscores in the specified word with dashes.
*
- *
+ *
+ * Inflector Rules
*
* Input |
* Output |
@@ -319,7 +322,8 @@ public String dasherize(String word) {
* Remove any package name from a fully qualified class name, returning only
* the simple classname.
*
- *
+ *
+ * Inflector Rules
*
* Input |
* Output |
@@ -363,7 +367,8 @@ public String foreignKey(String className) {
* Create and return a foreign key name from a class name, optionally
* inserting an underscore before the "id" portion.
*
- *
+ *
+ * Inflector Rules
*
* Input |
* Output |
@@ -403,7 +408,8 @@ public String foreignKey(String className, boolean underscore) {
* titleize()
, this is meant for creating pretty output, and is
* not intended for code generation.
*
- *
+ *
+ * Inflector Rules
*
* Input |
* Output |
@@ -444,7 +450,8 @@ public String humanize(String words) {
* Turn a number into a corresponding ordinal string used to denote the
* position in an ordered sequence.
*
- *
+ *
+ * Inflector Rules
*
* Input |
* Output |
@@ -560,7 +567,8 @@ public String singularize(String word) {
* database table, by uncamelizing, inserting underscores, and pluralizing
* the last word.
*
- *
+ *
+ * Inflector Rules
*
* Input |
* Output |
@@ -589,7 +597,8 @@ public String tableize(String className) {
* create a nicer looking title. This is meant for creating pretty output,
* and is not intended for code generation.
*
- *
+ *
+ * Inflector Rules
*
* Input |
* Output |
@@ -635,7 +644,8 @@ public String titleize(String words) {
* the expression in the string. Changes "." to "/" to convert fully
* qualified class names into paths.
*
- *
+ *
+ * Inflector Rules
*
* Input |
* Output |
diff --git a/starter-generator/src/main/java/fish/payara/starter/application/util/StringHelper.java b/starter-generator/src/main/java/fish/payara/starter/application/util/StringHelper.java
index 94efa7e..d86d2d6 100644
--- a/starter-generator/src/main/java/fish/payara/starter/application/util/StringHelper.java
+++ b/starter-generator/src/main/java/fish/payara/starter/application/util/StringHelper.java
@@ -49,12 +49,12 @@ public static String titleCase(String string) {
/**
* Converts `string` to [start case]
*
+ * startCase('--foo-bar--') => 'Foo Bar' startCase('fooBar') => 'Foo Bar'
+ * startCase('__FOO_BAR__') => 'FOO BAR'
+ *
* @param content
* @return
- * @example
*
- * startCase('--foo-bar--') => 'Foo Bar' startCase('fooBar') => 'Foo Bar'
- * startCase('__FOO_BAR__') => 'FOO BAR'
*/
public static String startCase(String content) {
StringBuilder result = new StringBuilder();
@@ -68,12 +68,10 @@ public static String startCase(String content) {
/**
* Converts `string` to [snake case]
+ * Foo Bar > 'foo_bar', fooBar > 'foo_bar', --FOO-BAR-- > 'foo_bar'
*
* @param content
* @return
- * @example
- *
- * Foo Bar > 'foo_bar', fooBar > 'foo_bar', --FOO-BAR-- > 'foo_bar'
*/
public static String snakeCase(String content) {
StringBuilder result = new StringBuilder();
@@ -87,12 +85,11 @@ public static String snakeCase(String content) {
/**
* Converts `string` to [kebab case]
+ * 'Foo Bar > 'foo-bar', 'fooBar' > 'foo-bar', '__FOO_BAR__' > 'foo-bar'
*
* @param content
* @return
- * @example
*
- * 'Foo Bar > 'foo-bar', 'fooBar' > 'foo-bar', '__FOO_BAR__' > 'foo-bar'
*/
public static String kebabCase(String content) {
StringBuilder result = new StringBuilder();
@@ -108,15 +105,14 @@ public static String kebabCase(String content) {
* Removes leading and trailing whitespace or specified characters from
* `string`.
*
- * @param content
- * @param trimmer
- * @return
- * @example
- *
* _.trim(' abc ', ' '); // => 'abc'
*
* _.trim('_abc_', '_'); // => 'abc'
*
+ * @param content
+ * @param trimmer
+ * @return
+ *
*/
public static String trim(String content, char trimmer) {
char value[] = content.toCharArray();
@@ -137,11 +133,10 @@ public static String trim(String content, char trimmer) {
/**
* Converts `string` to [camel case]
*
+ * 'Foo Bar > 'fooBar', '--foo-bar--' > 'fooBar', '__FOO_BAR__ > 'fooBar'
+ *
* @param content
* @return
- * @example
- *
- * 'Foo Bar > 'fooBar', '--foo-bar--' > 'fooBar', '__FOO_BAR__ > 'fooBar'
*/
public static String camelCase(String content) {
StringBuilder result = new StringBuilder();
@@ -160,12 +155,12 @@ public static String camelCase(String content) {
}
/**
+ * Convert to natural language
+ * BankAccount => Bank Account Bank_Account => Bank_Account
*
* @param input
* @return
- * @example
*
- * BankAccount => Bank Account Bank_Account => Bank_Account
*/
public static String toNatural(String input) {
String natural = EMPTY;
@@ -191,12 +186,11 @@ public static String toNatural(String input) {
}
/**
- *
+ * Convert to constant
+ * BankAccount => BANK_ACCOUNT Bank_Account => BANK_ACCOUNT
* @param input
* @return
- * @example
*
- * BankAccount => BANK_ACCOUNT Bank_Account => BANK_ACCOUNT
*/
public static String toConstant(String input) {
String constant = EMPTY;