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

JavaServer.pojo.mustache Maven / Gradle / Ivy

Go to download

This artefact generates other artefacts such as API client, API server out of API Model

There is a newer version: 1.1.1
Show newest version
@ApiModel{{#description}}(description = "{{{description}}}"){{/description}}
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {

  {{#vars}}
    {{#isEnum}}
    {{^isContainer}}
{{>enumClass}}
    {{/isContainer}}
    {{#isContainer}}
    {{#mostInnerItems}} 
{{>enumClass}}
    {{/mostInnerItems}}
    {{/isContainer}}
    {{/isEnum}}
    /**
    {{#description}}
     * {{{description}}}
    {{/description}}
    {{^description}}
     * Get {{name}}
    {{/description}}
    {{#minimum}}
     * minimum: {{minimum}}
    {{/minimum}}
    {{#maximum}}
     * maximum: {{maximum}}
    {{/maximum}}
     */
    {{#vendorExtensions.extraAnnotation}}
        {{{vendorExtensions.extraAnnotation}}}
    {{/vendorExtensions.extraAnnotation}}
    {{#isContainer}}
    {{#useBeanValidation}}@Valid{{/useBeanValidation}}
    private {{{datatypeWithEnum}}} {{name}};
  {{/isContainer}}
  {{^isContainer}}
    private {{{datatypeWithEnum}}} {{name}};
  {{/isContainer}}

  {{/vars}}
  {{#vars}}
    public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
        this.{{name}} = {{name}};
        return this;
    }
  {{#isListContainer}}

    public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
    {{^required}}
        if (this.{{name}} == null{{#isNullable}} || !this.{{name}}.isPresent(){{/isNullable}}) {
            this.{{name}} = {{#isNullable}}JsonNullable.of({{{defaultValue}}}){{/isNullable}}{{^isNullable}}{{{defaultValue}}}{{/isNullable}};
        }
    {{/required}}
        this.{{name}}{{#isNullable}}.get(){{/isNullable}}.add({{name}}Item);
        return this;
    }
  {{/isListContainer}}
  {{#isMapContainer}}

    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;
    }
  {{/isMapContainer}}

    @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}")
    {{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}}public {{{datatypeWithEnum}}} {{getter}}() {
        return {{name}};
    }

    public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
        this.{{name}} = {{name}};
    }
  {{/vars}}

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }{{#hasVars}}
        {{classname}} {{classVarName}} = ({{classname}}) o;
        return {{#nonInheritedVars}}{{#isByteArray}}Arrays{{/isByteArray}}{{#isBinary}}Arrays{{/isBinary}}{{^isByteArray}}{{^isBinary}}Objects{{/isBinary}}{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{^-last}} &&
            {{/-last}}{{/nonInheritedVars}}{{#parent}} &&
            super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}}
        return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};{{/hasVars}}
    }

    @Override
    public int hashCode() {
        return Objects.hash({{#nonInheritedVars}}
            {{^isByteArray}}{{^isBinary}}{{name}}{{/isBinary}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{#isBinary}}Arrays.hashCode({{name}}){{/isBinary}}{{^-last}},{{/-last}}{{/nonInheritedVars}}{{#parent}}{{#hasVars}},
            {{/hasVars}}super.hashCode(){{/parent}});
    }

    @Override
    public String toString() {
        return "class {{classname}} {\n" +{{#vars}}
            "   {{name}}: " + toIndentedString({{^isInherited}}{{name}}{{/isInherited}}{{#isInherited}}{{getter}}(){{/isInherited}}) + "\n" + {{/vars}}
            "}";
    }{{#hasVars}}

    /**
     * Convert the given object to string with each line indented by 4 spaces
     * (except the first line).
     */
    private String toIndentedString(Object o) {
        if (o == null) {
            return "null";
        }
        return o.toString().replace("\n", "\n    ");
    }{{/hasVars}}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy