Yuta HIGUCHI | 5a016cf | 2016-12-20 15:19:22 -0800 | [diff] [blame] | 1 | /** |
| 2 | * {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}} |
| 3 | */{{#description}} |
| 4 | @ApiModel(description = "{{{description}}}"){{/description}} |
| 5 | {{>generatedAnnotation}} |
| 6 | public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { |
| 7 | {{#vars}} |
| 8 | {{#isEnum}} |
| 9 | {{^isContainer}} |
| 10 | {{>enumClass}} |
| 11 | {{/isContainer}} |
| 12 | {{/isEnum}} |
| 13 | {{#items.isEnum}} |
| 14 | {{#items}} |
| 15 | {{^isContainer}} |
| 16 | {{>enumClass}} |
| 17 | {{/isContainer}} |
| 18 | {{/items}} |
| 19 | {{/items.isEnum}} |
| 20 | {{#jackson}} |
| 21 | @JsonProperty("{{baseName}}") |
| 22 | {{/jackson}} |
| 23 | {{#gson}} |
| 24 | @SerializedName("{{baseName}}") |
| 25 | {{/gson}} |
| 26 | private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; |
| 27 | |
| 28 | {{/vars}} |
| 29 | {{#vars}} |
| 30 | {{^isReadOnly}} |
| 31 | public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) { |
| 32 | this.{{name}} = {{name}}; |
| 33 | return this; |
| 34 | } |
| 35 | {{#isListContainer}} |
| 36 | |
| 37 | public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { |
| 38 | this.{{name}}.add({{name}}Item); |
| 39 | return this; |
| 40 | } |
| 41 | {{/isListContainer}} |
| 42 | {{#isMapContainer}} |
| 43 | |
| 44 | public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { |
| 45 | this.{{name}}.put(key, {{name}}Item); |
| 46 | return this; |
| 47 | } |
| 48 | {{/isMapContainer}} |
| 49 | |
| 50 | {{/isReadOnly}} |
| 51 | /** |
| 52 | {{#description}} |
| 53 | * {{{description}}} |
| 54 | {{/description}} |
| 55 | {{^description}} |
| 56 | * Get {{name}} |
| 57 | {{/description}} |
| 58 | {{#minimum}} |
| 59 | * minimum: {{minimum}} |
| 60 | {{/minimum}} |
| 61 | {{#maximum}} |
| 62 | * maximum: {{maximum}} |
| 63 | {{/maximum}} |
| 64 | * @return {{name}} |
| 65 | **/ |
| 66 | {{#vendorExtensions.extraAnnotation}} |
| 67 | {{vendorExtensions.extraAnnotation}} |
| 68 | {{/vendorExtensions.extraAnnotation}} |
| 69 | {{#jackson}} |
| 70 | @JsonProperty("{{baseName}}") |
| 71 | {{/jackson}} |
| 72 | @ApiModelProperty({{#example}}example = "{{example}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") |
| 73 | public {{{datatypeWithEnum}}} {{getter}}() { |
| 74 | return {{name}}; |
| 75 | } |
| 76 | {{^isReadOnly}} |
| 77 | |
| 78 | public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { |
| 79 | this.{{name}} = {{name}}; |
| 80 | } |
| 81 | {{/isReadOnly}} |
| 82 | |
| 83 | {{/vars}} |
| 84 | |
| 85 | {{^supportJava6}} |
| 86 | @Override |
| 87 | public boolean equals(java.lang.Object o) { |
| 88 | if (this == o) { |
| 89 | return true; |
| 90 | } |
| 91 | if (o == null || getClass() != o.getClass()) { |
| 92 | return false; |
| 93 | }{{#hasVars}} |
| 94 | {{classname}} {{classVarName}} = ({{classname}}) o; |
| 95 | return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} && |
| 96 | {{/hasMore}}{{/vars}}{{#parent}} && |
| 97 | super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} |
| 98 | return true;{{/hasVars}} |
| 99 | } |
| 100 | |
| 101 | @Override |
| 102 | public int hashCode() { |
| 103 | return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}); |
| 104 | } |
| 105 | |
| 106 | {{/supportJava6}} |
| 107 | {{#supportJava6}} |
| 108 | @Override |
| 109 | public boolean equals(java.lang.Object o) { |
| 110 | if (this == o) { |
| 111 | return true; |
| 112 | } |
| 113 | if (o == null || getClass() != o.getClass()) { |
| 114 | return false; |
| 115 | }{{#hasVars}} |
| 116 | {{classname}} {{classVarName}} = ({{classname}}) o; |
| 117 | return {{#vars}}ObjectUtils.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} && |
| 118 | {{/hasMore}}{{/vars}}{{#parent}} && |
| 119 | super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} |
| 120 | return true;{{/hasVars}} |
| 121 | } |
| 122 | |
| 123 | @Override |
| 124 | public int hashCode() { |
| 125 | return ObjectUtils.hashCodeMulti({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}); |
| 126 | } |
| 127 | |
| 128 | {{/supportJava6}} |
| 129 | |
| 130 | @Override |
| 131 | public String toString() { |
| 132 | StringBuilder sb = new StringBuilder(); |
| 133 | sb.append("class {{classname}} {\n"); |
| 134 | {{#parent}}sb.append(" ").append(toIndentedString(super.toString())).append("\n");{{/parent}} |
| 135 | {{#vars}}sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n"); |
| 136 | {{/vars}}sb.append("}"); |
| 137 | return sb.toString(); |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Convert the given object to string with each line indented by 4 spaces |
| 142 | * (except the first line). |
| 143 | */ |
| 144 | private String toIndentedString(java.lang.Object o) { |
| 145 | if (o == null) { |
| 146 | return "null"; |
| 147 | } |
| 148 | return o.toString().replace("\n", "\n "); |
| 149 | } |
| 150 | } |