All Downloads are FREE. Search and download functionalities are using the official Maven repository.

handlebars.JavaFluent.pojo.mustache Maven / Gradle / Ivy

There is a newer version: 1.14.0
Show newest version
/**
 * {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
 */
{{#description}}{{#useOas2}}@ApiModel{{/useOas2}}{{^useOas2}}@Schema{{/useOas2}}(description = "{{{description}}}"){{/description}}
{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
{{#generateBuilders}}@Buildable(editableEnabled = {{editableEnabled}}, validationEnabled = {{validationEnabled}}, lazyMapInitEnabled = {{lazyMapInitEnabled}}, generateBuilderPackage = {{generateBuilderPackage}}, builderPackage = "{{builderPackage}}"){{/generateBuilders}}
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}}


  public {{classname}}({{#vars}}{{{datatypeWithEnum}}} {{name}}{{#if hasMore}}, {{/if}}{{/vars}}) {
    {{#vars}}
        this.{{name}} = {{name}};
    {{/vars}}
  }

  {{#vars}}
  {{#isNot this 'read-only'}}
  public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
    this.{{name}} = {{name}};
    return this;
  }
  {{/isNot}}
  /**
  {{#if description}}
  * {{description}}
  {{/if}}
  {{#unless description}}
  * Get {{name}}
  {{/unless}}
  {{#if minimum}}
  * minimum: {{minimum}}
  {{/if}}
  {{#if maximum}}
  * maximum: {{maximum}}
  {{/if}}
  * @return {{name}}
  **/
  {{#if useBeanValidation}}
  {{>beanValidation}}
  {{/if}}
  {{#useOas2}}
  @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
  {{/useOas2}}
  {{^useOas2}}
  @Schema({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}description = "{{{description}}}")
  {{/useOas2}}
  {{#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 java.util.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) {
    {{#isNot this 'container'}}
    {{#parent}} super.writeToParcel(out, flags); {{/parent}}
    {{/isNot}}
    {{#vars}}
    out.writeValue({{name}});
    {{/vars}}
  }

  public {{classname}}() {
    super();
  }

  {{classname}}(Parcel in) {
    {{#isNot this 'container'}}
    {{#parent}} super(in); {{/parent}}
    {{/isNot}}
    {{#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