|
| 1 | +/** |
| 2 | + * {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}} |
| 3 | + */{{#description}} |
| 4 | +@ApiModel(description = "{{{description}}}"){{/description}} |
| 5 | +{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}} |
| 6 | +public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcelableModel}}implements Parcelable {{#serializableModel}}, Serializable {{/serializableModel}}{{/parcelableModel}}{{^parcelableModel}}{{#serializableModel}}implements Serializable {{/serializableModel}}{{/parcelableModel}}{ |
| 7 | +{{#serializableModel}} |
| 8 | + private static final long serialVersionUID = 1L; |
| 9 | + |
| 10 | +{{/serializableModel}} |
| 11 | + {{#vars}} |
| 12 | + {{#isEnum}} |
| 13 | + {{^isContainer}} |
| 14 | +{{>modelInnerEnum}} |
| 15 | + {{/isContainer}} |
| 16 | + {{/isEnum}} |
| 17 | + {{#items.isEnum}} |
| 18 | + {{#items}} |
| 19 | + {{^isContainer}} |
| 20 | +{{>modelInnerEnum}} |
| 21 | + {{/isContainer}} |
| 22 | + {{/items}} |
| 23 | + {{/items.isEnum}} |
| 24 | + {{#jackson}} |
| 25 | + @JsonProperty("{{baseName}}") |
| 26 | + {{#withXml}} |
| 27 | + @JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") |
| 28 | + {{/withXml}} |
| 29 | + {{/jackson}} |
| 30 | + {{#withXml}} |
| 31 | + {{#isXmlAttribute}} |
| 32 | + @XmlAttribute(name = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") |
| 33 | + {{/isXmlAttribute}} |
| 34 | + {{^isXmlAttribute}} |
| 35 | + @XmlElement({{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}name = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") |
| 36 | + {{/isXmlAttribute}} |
| 37 | + {{/withXml}} |
| 38 | + {{#gson}} |
| 39 | + @SerializedName("{{baseName}}") |
| 40 | + {{/gson}} |
| 41 | + {{#isContainer}} |
| 42 | + private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}}; |
| 43 | + {{/isContainer}} |
| 44 | + {{^isContainer}} |
| 45 | + private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; |
| 46 | + {{/isContainer}} |
| 47 | + |
| 48 | + {{/vars}} |
| 49 | + {{#vars}} |
| 50 | + {{^isReadOnly}} |
| 51 | + public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) { |
| 52 | + this.{{name}} = {{name}}; |
| 53 | + return this; |
| 54 | + } |
| 55 | + {{#isListContainer}} |
| 56 | + |
| 57 | + public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { |
| 58 | + {{^required}} |
| 59 | + if (this.{{name}} == null) { |
| 60 | + this.{{name}} = {{{defaultValue}}}; |
| 61 | + } |
| 62 | + {{/required}} |
| 63 | + this.{{name}}.add({{name}}Item); |
| 64 | + return this; |
| 65 | + } |
| 66 | + {{/isListContainer}} |
| 67 | + {{#isMapContainer}} |
| 68 | + |
| 69 | + public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { |
| 70 | + {{^required}} |
| 71 | + if (this.{{name}} == null) { |
| 72 | + this.{{name}} = {{{defaultValue}}}; |
| 73 | + } |
| 74 | + {{/required}} |
| 75 | + this.{{name}}.put(key, {{name}}Item); |
| 76 | + return this; |
| 77 | + } |
| 78 | + {{/isMapContainer}} |
| 79 | + |
| 80 | + {{/isReadOnly}} |
| 81 | + /** |
| 82 | + {{#description}} |
| 83 | + * {{description}} |
| 84 | + {{/description}} |
| 85 | + {{^description}} |
| 86 | + * Get {{name}} |
| 87 | + {{/description}} |
| 88 | + {{#minimum}} |
| 89 | + * minimum: {{minimum}} |
| 90 | + {{/minimum}} |
| 91 | + {{#maximum}} |
| 92 | + * maximum: {{maximum}} |
| 93 | + {{/maximum}} |
| 94 | + * @return {{name}} |
| 95 | + **/ |
| 96 | +{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") |
| 97 | +{{#vendorExtensions.extraAnnotation}} |
| 98 | + {{{vendorExtensions.extraAnnotation}}} |
| 99 | +{{/vendorExtensions.extraAnnotation}} |
| 100 | + public {{{datatypeWithEnum}}} {{getter}}() { |
| 101 | + return {{name}}; |
| 102 | + } |
| 103 | + {{^isReadOnly}} |
| 104 | + |
| 105 | + public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { |
| 106 | + this.{{name}} = {{name}}; |
| 107 | + } |
| 108 | + {{/isReadOnly}} |
| 109 | + |
| 110 | + {{/vars}} |
| 111 | + |
| 112 | +{{^supportJava6}} |
| 113 | + @Override |
| 114 | + public boolean equals(java.lang.Object o) { |
| 115 | + if (this == o) { |
| 116 | + return true; |
| 117 | + } |
| 118 | + if (o == null || getClass() != o.getClass()) { |
| 119 | + return false; |
| 120 | + }{{#hasVars}} |
| 121 | + {{classname}} {{classVarName}} = ({{classname}}) o; |
| 122 | + return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} && |
| 123 | + {{/hasMore}}{{/vars}}{{#parent}} && |
| 124 | + super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} |
| 125 | + return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};{{/hasVars}} |
| 126 | + } |
| 127 | + |
| 128 | + @Override |
| 129 | + public int hashCode() { |
| 130 | + return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}); |
| 131 | + } |
| 132 | + |
| 133 | +{{/supportJava6}} |
| 134 | +{{#supportJava6}} |
| 135 | + @Override |
| 136 | + public boolean equals(java.lang.Object o) { |
| 137 | + if (this == o) { |
| 138 | + return true; |
| 139 | + } |
| 140 | + if (o == null || getClass() != o.getClass()) { |
| 141 | + return false; |
| 142 | + }{{#hasVars}} |
| 143 | + {{classname}} {{classVarName}} = ({{classname}}) o; |
| 144 | + return {{#vars}}ObjectUtils.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} && |
| 145 | + {{/hasMore}}{{/vars}}{{#parent}} && |
| 146 | + super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} |
| 147 | + return true;{{/hasVars}} |
| 148 | + } |
| 149 | + |
| 150 | + @Override |
| 151 | + public int hashCode() { |
| 152 | + return ObjectUtils.hashCodeMulti({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}); |
| 153 | + } |
| 154 | + |
| 155 | +{{/supportJava6}} |
| 156 | + |
| 157 | + @Override |
| 158 | + public String toString() { |
| 159 | + StringBuilder sb = new StringBuilder(); |
| 160 | + sb.append("class {{classname}} {\n"); |
| 161 | + {{#parent}}sb.append(" ").append(toIndentedString(super.toString())).append("\n");{{/parent}} |
| 162 | + {{#vars}}if ({{name}} != null) sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n"); |
| 163 | + {{/vars}}sb.append("}"); |
| 164 | + return sb.toString(); |
| 165 | + } |
| 166 | + |
| 167 | + /** |
| 168 | + * Convert the given object to string with each line indented by 4 spaces |
| 169 | + * (except the first line). |
| 170 | + */ |
| 171 | + private String toIndentedString(java.lang.Object o) { |
| 172 | + if (o == null) { |
| 173 | + // return "null"; |
| 174 | + } |
| 175 | + return o.toString().replace("\n", "\n "); |
| 176 | + } |
| 177 | + |
| 178 | + {{#parcelableModel}} |
| 179 | + public void writeToParcel(Parcel out, int flags) { |
| 180 | + {{#parent}} super.writeToParcel(out, flags); {{/parent}} {{#vars}} |
| 181 | + out.writeValue({{name}}); |
| 182 | + {{/vars}} |
| 183 | + } |
| 184 | + |
| 185 | + public {{classname}}() { |
| 186 | + super(); |
| 187 | + } |
| 188 | + |
| 189 | + {{classname}}(Parcel in) { |
| 190 | + {{#parent}} super(in); {{/parent}} |
| 191 | + {{#vars}} |
| 192 | + {{#isPrimitiveType}} |
| 193 | + {{name}} = ({{{datatypeWithEnum}}})in.readValue(null); |
| 194 | + {{/isPrimitiveType}} |
| 195 | + {{^isPrimitiveType}} |
| 196 | + {{name}} = ({{{datatypeWithEnum}}})in.readValue({{complexType}}.class.getClassLoader()); |
| 197 | + {{/isPrimitiveType}} |
| 198 | + {{/vars}} |
| 199 | + } |
| 200 | + |
| 201 | + public int describeContents() { |
| 202 | + return 0; |
| 203 | + } |
| 204 | + |
| 205 | + public static final Parcelable.Creator<{{classname}}> CREATOR = new Parcelable.Creator<{{classname}}>() { |
| 206 | + public {{classname}} createFromParcel(Parcel in) { |
| 207 | + return new {{classname}}(in); |
| 208 | + } |
| 209 | + public {{classname}}[] newArray(int size) { |
| 210 | + return new {{classname}}[size]; |
| 211 | + } |
| 212 | + }; |
| 213 | + {{/parcelableModel}} |
| 214 | +} |
0 commit comments