github.com/optim-corp/cios-golang-sdk@v0.5.1/openapi/codegen/spring-cloud/pojo.mustache (about)

     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}}{{^parent}}{{#hateoas}}extends ResourceSupport {{/hateoas}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
     7  {{#serializableModel}}
     8    private static final long serialVersionUID = 1L;
     9  
    10  {{/serializableModel}}
    11    {{#vars}}
    12      {{#isEnum}}
    13      {{^isContainer}}
    14  {{>enumClass}}
    15      {{/isContainer}}
    16      {{#isContainer}}
    17      {{#mostInnerItems}} 
    18  {{>enumClass}}
    19      {{/mostInnerItems}}
    20      {{/isContainer}}
    21      {{/isEnum}}
    22    {{#jackson}}
    23    @JsonProperty("{{baseName}}"){{#withXml}}
    24    @JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}"){{/withXml}}
    25    {{/jackson}}
    26    {{#gson}}
    27    @SerializedName("{{baseName}}")
    28    {{/gson}}
    29    {{#isContainer}}
    30    {{#useBeanValidation}}@Valid{{/useBeanValidation}}
    31    private {{>nullableDataType}} {{name}} = {{#isNullable}}JsonNullable.undefined(){{/isNullable}}{{^isNullable}}{{#required}}{{{defaultValue}}}{{/required}}{{^required}}null{{/required}}{{/isNullable}};
    32    {{/isContainer}}
    33    {{^isContainer}}
    34    private {{>nullableDataType}} {{name}}{{#isNullable}} = JsonNullable.undefined(){{/isNullable}}{{^isNullable}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/isNullable}};
    35    {{/isContainer}}
    36  
    37    {{/vars}}
    38    {{#vars}}
    39    public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
    40      this.{{name}} = {{#isNullable}}JsonNullable.of({{name}}){{/isNullable}}{{^isNullable}}{{name}}{{/isNullable}};
    41      return this;
    42    }
    43    {{#isListContainer}}
    44  
    45    public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
    46      {{^required}}
    47      if (this.{{name}} == null) {
    48        this.{{name}} = {{#isNullable}}JsonNullable.of({{{defaultValue}}}){{/isNullable}}{{^isNullable}}{{{defaultValue}}}{{/isNullable}};
    49      }
    50      {{/required}}
    51      this.{{#isNullable}}{{name}}.get(){{/isNullable}}{{^isNullable}}{{name}}{{/isNullable}}.add({{name}}Item);
    52      return this;
    53    }
    54    {{/isListContainer}}
    55    {{#isMapContainer}}
    56  
    57    public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
    58      {{^required}}
    59      if (this.{{name}} == null) {
    60        this.{{name}} = {{{defaultValue}}};
    61      }
    62      {{/required}}
    63      this.{{name}}.put(key, {{name}}Item);
    64      return this;
    65    }
    66    {{/isMapContainer}}
    67  
    68    /**
    69    {{#description}}
    70     * {{{description}}}
    71    {{/description}}
    72    {{^description}}
    73     * Get {{name}}
    74    {{/description}}
    75    {{#minimum}}
    76     * minimum: {{minimum}}
    77    {{/minimum}}
    78    {{#maximum}}
    79     * maximum: {{maximum}}
    80    {{/maximum}}
    81     * @return {{name}}
    82    */
    83   {{#vendorExtensions.extraAnnotation}}
    84    {{{vendorExtensions.extraAnnotation}}}
    85    {{/vendorExtensions.extraAnnotation}}
    86    @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}")
    87  {{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}}  public {{>nullableDataType}} {{getter}}() {
    88      return {{name}};
    89    }
    90  
    91    public void {{setter}}({{>nullableDataType}} {{name}}) {
    92      this.{{name}} = {{name}};
    93    }
    94  
    95    {{/vars}}
    96  
    97    @Override
    98    public boolean equals(java.lang.Object o) {
    99      if (this == o) {
   100        return true;
   101      }
   102      if (o == null || getClass() != o.getClass()) {
   103        return false;
   104      }{{#hasVars}}
   105      {{classname}} {{classVarName}} = ({{classname}}) o;
   106      return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
   107          {{/hasMore}}{{/vars}}{{#parent}} &&
   108          super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}}
   109      return true;{{/hasVars}}
   110    }
   111  
   112    @Override
   113    public int hashCode() {
   114      return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}});
   115    }
   116  
   117    @Override
   118    public String toString() {
   119      StringBuilder sb = new StringBuilder();
   120      sb.append("class {{classname}} {\n");
   121      {{#parent}}sb.append("    ").append(toIndentedString(super.toString())).append("\n");{{/parent}}
   122      {{#vars}}sb.append("    {{name}}: ").append(toIndentedString({{name}})).append("\n");
   123      {{/vars}}sb.append("}");
   124      return sb.toString();
   125    }
   126  
   127    /**
   128     * Convert the given object to string with each line indented by 4 spaces
   129     * (except the first line).
   130     */
   131    private String toIndentedString(java.lang.Object o) {
   132      if (o == null) {
   133        return "null";
   134      }
   135      return o.toString().replace("\n", "\n    ");
   136    }
   137  }