JavaClient.pojo.mustache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of codegen Show documentation
Show all versions of codegen Show documentation
This artefact generates other artefacts such as API client, API server out of API Model
{{#description}}/**
* {{.}}
*/{{/description}}
public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
{{#_enums}}
{{>modelInnerEnum}}
{{/_enums}}
{{#nonInheritedVars}}
{{#isContainer}}
private {{{datatypeWithEnum}}} {{name}};
{{/isContainer}}
{{^isContainer}}
private {{^isMeta}}{{{datatypeWithEnum}}}{{/isMeta}}{{#isMeta}}Object{{/isMeta}} {{name}}{{#isDefaultValueVisible}} = {{{defaultValue}}}{{/isDefaultValueVisible}};
{{/isContainer}}
{{/nonInheritedVars}}
{{#nonInheritedVars}}
/**
{{#description}}
* {{description}}
{{/description}}
{{^description}}
* Get {{name}}
{{/description}}
{{#minimum}}
* minimum: {{minimum}}
{{/minimum}}
{{#maximum}}
* maximum: {{maximum}}
{{/maximum}}
* @return {{name}}
*/
{{#vendorExtensions.extraAnnotation}}
{{{vendorExtensions.extraAnnotation}}}
{{/vendorExtensions.extraAnnotation}}
public {{^isMeta}}{{{datatypeWithEnum}}}{{/isMeta}}{{#isMeta}}Object{{/isMeta}} {{getter}}() {
return {{name}};
}
{{^isReadOnly}}
public void {{setter}}({{^isMeta}}{{{datatypeWithEnum}}}{{/isMeta}}{{#isMeta}}Object{{/isMeta}} {{name}}) {
this.{{name}} = {{name}};
}
{{/isReadOnly}}
{{/nonInheritedVars}}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}{{#hasVars}}
{{classname}} {{classVarName}} = ({{classname}}) o;
return {{#nonInheritedVars}}{{#isByteArray}}Arrays{{/isByteArray}}{{#isBinary}}Arrays{{/isBinary}}{{^isByteArray}}{{^isBinary}}Objects{{/isBinary}}{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{^-last}} &&
{{/-last}}{{/nonInheritedVars}}{{#parent}} &&
super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}}
return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};{{/hasVars}}
}
@Override
public int hashCode() {
return Objects.hash({{#nonInheritedVars}}
{{^isByteArray}}{{^isBinary}}{{name}}{{/isBinary}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{#isBinary}}Arrays.hashCode({{name}}){{/isBinary}}{{^-last}},{{/-last}}{{/nonInheritedVars}}{{#parent}}{{#hasVars}},
{{/hasVars}}super.hashCode(){{/parent}});
}
@Override
public String toString() {
return "class {{classname}} {\n" +{{#vars}}
" {{name}}: " + toIndentedString({{^isInherited}}{{name}}{{/isInherited}}{{#isInherited}}{{getter}}(){{/isInherited}}) + "\n" + {{/vars}}
"}";
}{{#hasVars}}
/**
* 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 ");
}{{/hasVars}}
}