
v2.Java.pojo.mustache Maven / Gradle / Ivy
The newest version!
/**
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
*/{{#description}}@ApiModel(description = "{{{description}}}"){{/description}}
{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
public class {{{getClassDefinition}}} {
{{#serializableModel}}
private static final long serialVersionUID = 1L;
{{/serializableModel~}}
{{#vars~}}
{{#baseItems this ~}}
{{#is this 'enum'}}
{{> modelInnerEnum}}
{{/is~}}
{{/baseItems}}
{{#if jackson}}
@JsonProperty("{{baseName}}")
{{#if withXml~}}
{{#isNot this 'container'~}}@JacksonXmlProperty({{{getJacksonXmlProperty this}}}){{/isNot}}
{{#is this 'container'~}}
{{#is this 'xml-wrapped'~}}
// items.xmlName={{items.xmlName}}
@JacksonXmlElementWrapper({{{getJacksonXmlElementWrapper this}}})
{{/is~}}
{{/is~}}
{{/if ~}}
{{/if~}}
{{#if withXml~}}
{{#is this 'xml-attribute'~}}
@XmlAttribute(name = "{{getXmlAttributeName xmlName baseName}}")
{{/is~}}
{{#isNot this 'xml-attribute'~}}
{{#isNot this 'container'~}}@XmlElement({{{getXmlElementName xmlNamespace xmlName baseName}}}){{/isNot}}
{{#is this 'container'~}}
{{#items~}}
@XmlElement({{{getXmlElementName items.xmlNamespace items.xmlName items.baseName}}})
{{/items~}}
{{#is this 'xml-wrapped'~}}@XmlElementWrapper({{{getXmlElementName xmlNamespace xmlName baseName}}}){{/is}}
{{/is~}}
{{/isNot~}}
{{/if~}}
{{#gson~}}
@SerializedName("{{baseName}}")
{{/gson~}}
private {{{getJavaProperty}}};
{{/vars}}
{{#vars~}}
{{#isNot this 'read-only'~}}
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
return this;
}
{{#is this 'list-container'}}public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
{{^required}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}};
}
{{/required}}
this.{{name}}.add({{name}}Item);
return this;
}
{{/is~}}
{{#is this 'map-container'}}public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
{{^required}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}};
}
{{/required}}
this.{{name}}.put(key, {{name}}Item);
return this;
}{{/is~}}
{{/isNot}}
/**
{{#if description~}}* {{description}}{{else}}* Get {{name}}{{/if}}
{{#if minimum~}}
* minimum: {{minimum}}
{{/if~}}
{{#if maximum~}}
* maximum: {{maximum}}
{{/if~}}
* @return {{name}}
**/
{{#if useBeanValidation}}{{>beanValidation}}{{/if}}@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
{{#vendorExtensions.extraAnnotation}}
{{{vendorExtensions.extraAnnotation}}}
{{/vendorExtensions.extraAnnotation~}}
public {{{datatypeWithEnum}}} {{getter}}() {
return {{name}};
}
{{#isNot this 'read-only'~}}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}
{{/isNot}}
{{/vars~}}
{{^supportJava6~}}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}{{#has this 'vars'}}
{{classname}} {{classVarName}} = ({{classname}}) o;
return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#has this 'more'}} &&
{{/has}}{{/vars}}{{#parent}} &&
super.equals(o){{/parent}};{{/has}}{{#hasNot this 'vars'}}
return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};{{/hasNot}}
}
@Override
public int hashCode() {
return Objects.hash({{#vars}}{{name}}{{#has this 'more'}}, {{/has}}{{/vars}}{{#if parent}}{{#has this 'vars'}}, {{/has}}super.hashCode(){{/if}});
}
{{/supportJava6~}}
{{#supportJava6~}}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}{{#has this 'vars'}}
{{classname}} {{classVarName}} = ({{classname}}) o;
return {{#vars}}ObjectUtils.equals(this.{{name}}, {{classVarName}}.{{name}}){{#has this 'more'}} &&
{{/has}}{{/vars}}{{#parent}} &&
super.equals(o){{/parent}};{{/has}}{{#hasNot this 'vars'}}
return true;{{/hasNot}}
}
@Override
public int hashCode() {
return ObjectUtils.hashCodeMulti({{#vars}}{{name}}{{#has this 'more'}}, {{/has}}{{/vars}}{{#if parent}}{{#has this 'vars'}}, {{/has}}super.hashCode(){{/if}});
}
{{/supportJava6~}}
@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(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
{{#parcelableModel}}
public void writeToParcel(Parcel out, int flags) {
{{#parent}} super.writeToParcel(out, flags); {{/parent}}
{{#vars~}}
out.writeValue({{name}});
{{/vars}}
}
public {{classname}}() {
super();
}
{{classname}}(Parcel in) {
{{#parent}} super(in); {{/parent}}
{{#vars~}}
{{#is this 'primitive-type'~}}{{name}} = ({{{datatypeWithEnum}}})in.readValue(null);{{/is~}}
{{#isNot this 'primitive-type'~}}{{name}} = ({{{datatypeWithEnum}}})in.readValue({{complexType}}.class.getClassLoader());{{/isNot~}}
{{/vars}}
}
public int describeContents() {
return 0;
}
public static final Parcelable.Creator<{{classname}}> CREATOR = new Parcelable.Creator<{{classname}}>() {
public {{classname}} createFromParcel(Parcel in) {
return new {{classname}}(in);
}
public {{classname}}[] newArray(int size) {
return new {{classname}}[size];
}
};{{/parcelableModel}}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy