forked from loafle/openapi-generator-original
Merge pull request #1790 from swagger-api/issue-1789
updated templates for pojos, enums
This commit is contained in:
commit
0c12971bbb
@ -702,25 +702,30 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
}
|
}
|
||||||
objs.put("models", models);
|
objs.put("models", models);
|
||||||
|
|
||||||
List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
|
Set<String> importSet = new TreeSet<String>();
|
||||||
for (String nextImport : allImports) {
|
for (String nextImport : allImports) {
|
||||||
Map<String, String> im = new LinkedHashMap<String, String>();
|
Map<String, String> im = new HashMap<String, String>();
|
||||||
String mapping = config.importMapping().get(nextImport);
|
String mapping = config.importMapping().get(nextImport);
|
||||||
if (mapping == null) {
|
if (mapping == null) {
|
||||||
mapping = config.toModelImport(nextImport);
|
mapping = config.toModelImport(nextImport);
|
||||||
}
|
}
|
||||||
if (mapping != null && !config.defaultIncludes().contains(mapping)) {
|
if (mapping != null && !config.defaultIncludes().contains(mapping)) {
|
||||||
im.put("import", mapping);
|
importSet.add(mapping);
|
||||||
imports.add(im);
|
|
||||||
}
|
}
|
||||||
// add instantiation types
|
// add instantiation types
|
||||||
mapping = config.instantiationTypes().get(nextImport);
|
mapping = config.instantiationTypes().get(nextImport);
|
||||||
if (mapping != null && !config.defaultIncludes().contains(mapping)) {
|
if (mapping != null && !config.defaultIncludes().contains(mapping)) {
|
||||||
im.put("import", mapping);
|
importSet.add(mapping);
|
||||||
imports.add(im);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
|
||||||
|
for(String s: importSet) {
|
||||||
|
Map<String, String> item = new HashMap<String, String>();
|
||||||
|
item.put("import", s);
|
||||||
|
imports.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
objs.put("imports", imports);
|
objs.put("imports", imports);
|
||||||
config.postProcessModels(objs);
|
config.postProcessModels(objs);
|
||||||
|
|
||||||
|
@ -73,6 +73,8 @@ public class JavaInflectorServerCodegen extends JavaClientCodegen implements Cod
|
|||||||
"src/main/swagger",
|
"src/main/swagger",
|
||||||
"swagger.yaml")
|
"swagger.yaml")
|
||||||
);
|
);
|
||||||
|
supportingFiles.add(new SupportingFile("StringUtil.mustache",
|
||||||
|
(sourceFolder + '/' + invokerPackage).replace(".", "/"), "StringUtil.java"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -118,22 +120,6 @@ public class JavaInflectorServerCodegen extends JavaClientCodegen implements Cod
|
|||||||
co.baseName = basePath;
|
co.baseName = basePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
|
||||||
List<Object> models = (List<Object>) objs.get("models");
|
|
||||||
for (Object _mo : models) {
|
|
||||||
Map<String, Object> mo = (Map<String, Object>) _mo;
|
|
||||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
|
||||||
for (CodegenProperty var : cm.vars) {
|
|
||||||
// handle default value for enum, e.g. available => StatusEnum.available
|
|
||||||
if (var.isEnum && var.defaultValue != null && !"null".equals(var.defaultValue)) {
|
|
||||||
var.defaultValue = var.datatypeWithEnum + "." + var.defaultValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return objs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||||
|
@ -100,6 +100,8 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf
|
|||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java"));
|
(sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java"));
|
||||||
supportingFiles.add(new SupportingFile("web.mustache",
|
supportingFiles.add(new SupportingFile("web.mustache",
|
||||||
("src/main/webapp/WEB-INF"), "web.xml"));
|
("src/main/webapp/WEB-INF"), "web.xml"));
|
||||||
|
supportingFiles.add(new SupportingFile("StringUtil.mustache",
|
||||||
|
(sourceFolder + '/' + apiPackage).replace(".", "/"), "StringUtil.java"));
|
||||||
|
|
||||||
if (additionalProperties.containsKey("dateLibrary")) {
|
if (additionalProperties.containsKey("dateLibrary")) {
|
||||||
setDateLibrary(additionalProperties.get("dateLibrary").toString());
|
setDateLibrary(additionalProperties.get("dateLibrary").toString());
|
||||||
@ -204,22 +206,6 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
|
||||||
List<Object> models = (List<Object>) objs.get("models");
|
|
||||||
for (Object _mo : models) {
|
|
||||||
Map<String, Object> mo = (Map<String, Object>) _mo;
|
|
||||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
|
||||||
for (CodegenProperty var : cm.vars) {
|
|
||||||
// handle default value for enum, e.g. available => StatusEnum.available
|
|
||||||
if (var.isEnum && var.defaultValue != null && !"null".equals(var.defaultValue)) {
|
|
||||||
var.defaultValue = var.datatypeWithEnum + "." + var.defaultValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return objs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
package {{package}};
|
package {{package}};
|
||||||
|
|
||||||
import {{invokerPackage}}.StringUtil;
|
|
||||||
{{#imports}}import {{import}};
|
{{#imports}}import {{import}};
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
{{#serializableModel}}
|
{{#serializableModel}}import java.io.Serializable;{{/serializableModel}}
|
||||||
import java.io.Serializable;{{/serializableModel}}
|
|
||||||
|
|
||||||
{{#models}}
|
{{#models}}
|
||||||
|
|
||||||
{{#model}}{{#description}}
|
{{#model}}{{#description}}
|
||||||
/**
|
/**
|
||||||
* {{description}}
|
* {{description}}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@ApiModel(description = "{{{description}}}")
|
{{#description}}@ApiModel(description = "{{{description}}}"){{/description}}
|
||||||
{{>generatedAnnotation}}
|
{{>generatedAnnotation}}
|
||||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
|
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
|
||||||
{{#vars}}{{#isEnum}}
|
{{#vars}}{{#isEnum}}
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
package {{invokerPackage}};
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
|
public class StringUtil {
|
||||||
|
/**
|
||||||
|
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||||
|
*
|
||||||
|
* @param array The array
|
||||||
|
* @param value The value to search
|
||||||
|
* @return true if the array contains the value
|
||||||
|
*/
|
||||||
|
public static boolean containsIgnoreCase(String[] array, String value) {
|
||||||
|
for (String str : array) {
|
||||||
|
if (value == null && str == null) return true;
|
||||||
|
if (value != null && value.equalsIgnoreCase(str)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Join an array of strings with the given separator.
|
||||||
|
* <p>
|
||||||
|
* Note: This might be replaced by utility method from commons-lang or guava someday
|
||||||
|
* if one of those libraries is added as dependency.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param array The array of strings
|
||||||
|
* @param separator The separator
|
||||||
|
* @return the resulting string
|
||||||
|
*/
|
||||||
|
public static String join(String[] array, String separator) {
|
||||||
|
int len = array.length;
|
||||||
|
if (len == 0) return "";
|
||||||
|
|
||||||
|
StringBuilder out = new StringBuilder();
|
||||||
|
out.append(array[0]);
|
||||||
|
for (int i = 1; i < len; i++) {
|
||||||
|
out.append(separator).append(array[i]);
|
||||||
|
}
|
||||||
|
return out.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
public enum {{{datatypeWithEnum}}} {
|
||||||
|
{{#allowableValues}}{{#enumVars}}{{{name}}}("{{{value}}}"){{^-last}},
|
||||||
|
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
{{{datatypeWithEnum}}}(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonValue
|
||||||
|
public String toString() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
public enum {{classname}} {
|
||||||
|
{{#allowableValues}}{{.}}{{^-last}}, {{/-last}}{{/allowableValues}}
|
||||||
|
}
|
@ -3,50 +3,13 @@ package {{package}};
|
|||||||
{{#imports}}import {{import}};
|
{{#imports}}import {{import}};
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
import io.swagger.annotations.*;
|
{{#serializableModel}}import java.io.Serializable;{{/serializableModel}}
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
{{#models}}
|
{{#models}}
|
||||||
|
|
||||||
{{#model}}{{#description}}
|
{{#model}}{{#description}}
|
||||||
/**
|
/**
|
||||||
* {{description}}
|
* {{description}}
|
||||||
**/{{/description}}
|
**/{{/description}}
|
||||||
@ApiModel(description = "{{{description}}}")
|
{{#isEnum}}{{>enumOuterClass}}{{/isEnum}}
|
||||||
{{>generatedAnnotation}}
|
{{^isEnum}}{{>pojo}}{{/isEnum}}
|
||||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
|
||||||
{{#vars}}{{#isEnum}}
|
|
||||||
public enum {{datatypeWithEnum}} {
|
|
||||||
{{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}}
|
|
||||||
};
|
|
||||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{^isEnum}}
|
|
||||||
private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}}
|
|
||||||
|
|
||||||
{{#vars}}
|
|
||||||
/**{{#description}}
|
|
||||||
* {{{description}}}{{/description}}{{#minimum}}
|
|
||||||
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
|
|
||||||
* maximum: {{maximum}}{{/maximum}}
|
|
||||||
**/
|
|
||||||
@ApiModelProperty({{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
|
|
||||||
@JsonProperty("{{baseName}}")
|
|
||||||
public {{{datatypeWithEnum}}} {{getter}}() {
|
|
||||||
return {{name}};
|
|
||||||
}
|
|
||||||
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
|
||||||
this.{{name}} = {{name}};
|
|
||||||
}
|
|
||||||
|
|
||||||
{{/vars}}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("class {{classname}} {\n");
|
|
||||||
{{#parent}}sb.append(" " + super.toString()).append("\n");{{/parent}}
|
|
||||||
{{#vars}}sb.append(" {{name}}: ").append({{name}}).append("\n");
|
|
||||||
{{/vars}}sb.append("}\n");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{{/model}}
|
{{/model}}
|
||||||
{{/models}}
|
{{/models}}
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
{{#description}}@ApiModel(description = "{{{description}}}"){{/description}}
|
||||||
|
{{>generatedAnnotation}}
|
||||||
|
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
|
||||||
|
{{#vars}}{{#isEnum}}
|
||||||
|
|
||||||
|
{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
|
||||||
|
|
||||||
|
{{>enumClass}}{{/items}}{{/items.isEnum}}
|
||||||
|
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}
|
||||||
|
|
||||||
|
{{#vars}}
|
||||||
|
/**{{#description}}
|
||||||
|
* {{{description}}}{{/description}}{{#minimum}}
|
||||||
|
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
|
||||||
|
* maximum: {{maximum}}{{/maximum}}
|
||||||
|
**/
|
||||||
|
{{#vendorExtensions.extraAnnotation}}{{vendorExtensions.extraAnnotation}}{{/vendorExtensions.extraAnnotation}}
|
||||||
|
@ApiModelProperty({{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
|
||||||
|
@JsonProperty("{{baseName}}")
|
||||||
|
public {{{datatypeWithEnum}}} {{getter}}() {
|
||||||
|
return {{name}};
|
||||||
|
}
|
||||||
|
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
||||||
|
this.{{name}} = {{name}};
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/vars}}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
{{classname}} {{classVarName}} = ({{classname}}) o;{{#hasVars}}
|
||||||
|
return {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
|
||||||
|
{{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}}
|
||||||
|
return true;{{/hasVars}}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class {{classname}} {\n");
|
||||||
|
{{#parent}}sb.append(" ").append(toIndentedString(super.toString())).append("\n");{{/parent}}
|
||||||
|
{{#vars}}sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n");
|
||||||
|
{{/vars}}sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given object to string with each line indented by 4 spaces
|
||||||
|
* (except the first line).
|
||||||
|
*/
|
||||||
|
private String toIndentedString(Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return o.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package {{invokerPackage}};
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
|
public class StringUtil {
|
||||||
|
/**
|
||||||
|
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||||
|
*
|
||||||
|
* @param array The array
|
||||||
|
* @param value The value to search
|
||||||
|
* @return true if the array contains the value
|
||||||
|
*/
|
||||||
|
public static boolean containsIgnoreCase(String[] array, String value) {
|
||||||
|
for (String str : array) {
|
||||||
|
if (value == null && str == null) return true;
|
||||||
|
if (value != null && value.equalsIgnoreCase(str)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Join an array of strings with the given separator.
|
||||||
|
* <p>
|
||||||
|
* Note: This might be replaced by utility method from commons-lang or guava someday
|
||||||
|
* if one of those libraries is added as dependency.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param array The array of strings
|
||||||
|
* @param separator The separator
|
||||||
|
* @return the resulting string
|
||||||
|
*/
|
||||||
|
public static String join(String[] array, String separator) {
|
||||||
|
int len = array.length;
|
||||||
|
if (len == 0) return "";
|
||||||
|
|
||||||
|
StringBuilder out = new StringBuilder();
|
||||||
|
out.append(array[0]);
|
||||||
|
for (int i = 1; i < len; i++) {
|
||||||
|
out.append(separator).append(array[i]);
|
||||||
|
}
|
||||||
|
return out.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
public enum {{{datatypeWithEnum}}} {
|
||||||
|
{{#allowableValues}}{{#enumVars}}{{{name}}}("{{{value}}}"){{^-last}},
|
||||||
|
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
{{{datatypeWithEnum}}}(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonValue
|
||||||
|
public String toString() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
public enum {{classname}} {
|
||||||
|
{{#allowableValues}}{{.}}{{^-last}}, {{/-last}}{{/allowableValues}}
|
||||||
|
}
|
@ -3,71 +3,13 @@ package {{package}};
|
|||||||
{{#imports}}import {{import}};
|
{{#imports}}import {{import}};
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
import io.swagger.annotations.*;
|
{{#serializableModel}}import java.io.Serializable;{{/serializableModel}}
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
{{#models}}
|
{{#models}}
|
||||||
|
{{#model}}{{#description}}
|
||||||
{{#model}}{{#unescapedDescription}}
|
|
||||||
/**
|
/**
|
||||||
* {{unescapedDescription}}
|
* {{description}}
|
||||||
**/{{/unescapedDescription}}
|
**/{{/description}}
|
||||||
@ApiModel(description = "{{{description}}}")
|
{{#isEnum}}{{>enumOuterClass}}{{/isEnum}}
|
||||||
{{>generatedAnnotation}}
|
{{^isEnum}}{{>pojo}}{{/isEnum}}
|
||||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
|
||||||
{{#vars}}{{#isEnum}}
|
|
||||||
public enum {{datatypeWithEnum}} {
|
|
||||||
{{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}}
|
|
||||||
};
|
|
||||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{^isEnum}}
|
|
||||||
private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}}
|
|
||||||
|
|
||||||
{{#vars}}
|
|
||||||
/**{{#unescapedDescription}}
|
|
||||||
* {{{unescapedDescription}}}{{/unescapedDescription}}{{#minimum}}
|
|
||||||
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
|
|
||||||
* maximum: {{maximum}}{{/maximum}}
|
|
||||||
**/
|
|
||||||
@ApiModelProperty({{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
|
|
||||||
@JsonProperty("{{baseName}}")
|
|
||||||
public {{{datatypeWithEnum}}} {{getter}}() {
|
|
||||||
return {{name}};
|
|
||||||
}
|
|
||||||
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
|
||||||
this.{{name}} = {{name}};
|
|
||||||
}
|
|
||||||
|
|
||||||
{{/vars}}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
{{classname}} {{classVarName}} = ({{classname}}) o;{{#hasVars}}
|
|
||||||
return {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
|
|
||||||
{{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}}
|
|
||||||
return true;{{/hasVars}}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("class {{classname}} {\n");
|
|
||||||
{{#parent}}sb.append(" " + super.toString()).append("\n");{{/parent}}
|
|
||||||
{{#vars}}sb.append(" {{name}}: ").append({{name}}).append("\n");
|
|
||||||
{{/vars}}sb.append("}\n");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{{/model}}
|
{{/model}}
|
||||||
{{/models}}
|
{{/models}}
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
{{#description}}@ApiModel(description = "{{{description}}}"){{/description}}
|
||||||
|
{{>generatedAnnotation}}
|
||||||
|
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
|
||||||
|
{{#vars}}{{#isEnum}}
|
||||||
|
|
||||||
|
{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
|
||||||
|
|
||||||
|
{{>enumClass}}{{/items}}{{/items.isEnum}}
|
||||||
|
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}
|
||||||
|
|
||||||
|
{{#vars}}
|
||||||
|
/**{{#description}}
|
||||||
|
* {{{description}}}{{/description}}{{#minimum}}
|
||||||
|
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
|
||||||
|
* maximum: {{maximum}}{{/maximum}}
|
||||||
|
**/
|
||||||
|
{{#vendorExtensions.extraAnnotation}}{{vendorExtensions.extraAnnotation}}{{/vendorExtensions.extraAnnotation}}
|
||||||
|
@ApiModelProperty({{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
|
||||||
|
@JsonProperty("{{baseName}}")
|
||||||
|
public {{{datatypeWithEnum}}} {{getter}}() {
|
||||||
|
return {{name}};
|
||||||
|
}
|
||||||
|
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
||||||
|
this.{{name}} = {{name}};
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/vars}}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
{{classname}} {{classVarName}} = ({{classname}}) o;{{#hasVars}}
|
||||||
|
return {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
|
||||||
|
{{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}}
|
||||||
|
return true;{{/hasVars}}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class {{classname}} {\n");
|
||||||
|
{{#parent}}sb.append(" ").append(toIndentedString(super.toString())).append("\n");{{/parent}}
|
||||||
|
{{#vars}}sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n");
|
||||||
|
{{/vars}}sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given object to string with each line indented by 4 spaces
|
||||||
|
* (except the first line).
|
||||||
|
*/
|
||||||
|
private String toIndentedString(Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return o.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
}
|
40
pom.xml
40
pom.xml
@ -118,30 +118,6 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<version>2.7</version>
|
|
||||||
<configuration>
|
|
||||||
<aggregate>true</aggregate>
|
|
||||||
<source>1.6</source>
|
|
||||||
<encoding>UTF-8</encoding>
|
|
||||||
<maxmemory>1g</maxmemory>
|
|
||||||
<links>
|
|
||||||
<link>http://java.sun.com/javase/6/docs/api/</link>
|
|
||||||
</links>
|
|
||||||
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>attach-javadocs</id>
|
|
||||||
<phase>verify</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.0</version>
|
<version>3.0</version>
|
||||||
@ -186,7 +162,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>2.7</version>
|
<version>2.9</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<aggregate>true</aggregate>
|
<aggregate>true</aggregate>
|
||||||
<source>1.6</source>
|
<source>1.6</source>
|
||||||
@ -495,20 +471,6 @@
|
|||||||
<reporting>
|
<reporting>
|
||||||
<outputDirectory>target/site</outputDirectory>
|
<outputDirectory>target/site</outputDirectory>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<version>2.9</version>
|
|
||||||
<configuration>
|
|
||||||
<aggregate>true</aggregate>
|
|
||||||
<debug>true</debug>
|
|
||||||
<links>
|
|
||||||
<link>http://java.sun.com/javaee/5/docs/api</link>
|
|
||||||
<link>http://java.sun.com/j2se/1.5.0/docs/api</link>
|
|
||||||
</links>
|
|
||||||
<excludePackageNames/>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>net.alchim31.maven</groupId>
|
<groupId>net.alchim31.maven</groupId>
|
||||||
<artifactId>scala-maven-plugin</artifactId>
|
<artifactId>scala-maven-plugin</artifactId>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user