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

JavaJaxRS.spec.pojo.mustache Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
{{#useSwaggerAnnotations}}
import io.swagger.annotations.*;
{{/useSwaggerAnnotations}}
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.annotation.JsonTypeName;

{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{#description}}/**
 * {{.}}
 **/{{/description}}
{{#useSwaggerAnnotations}}{{#description}}@ApiModel(description = "{{{.}}}"){{/description}}{{/useSwaggerAnnotations}}{{#useMicroProfileOpenAPIAnnotations}}
@org.eclipse.microprofile.openapi.annotations.media.Schema({{#title}}title="{{{.}}}", {{/title}}{{#description}}description="{{{.}}}"{{/description}}{{^description}}description=""{{/description}}){{/useMicroProfileOpenAPIAnnotations}}
@JsonTypeName("{{name}}")
{{>generatedAnnotation}}{{>additionalModelTypeAnnotations}}
{{#vendorExtensions.x-class-extra-annotation}}
{{{vendorExtensions.x-class-extra-annotation}}}
{{/vendorExtensions.x-class-extra-annotation}}
public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtensions.x-implements}}{{#-first}}implements {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} {
  {{#vars}}
  {{#isEnum}}
  {{^isContainer}}
  {{>enumClass}}
  {{/isContainer}}
  {{#isContainer}}
  {{#mostInnerItems}}
  {{>enumClass}}
  {{/mostInnerItems}}
  {{/isContainer}}
  {{/isEnum}}
  {{#vendorExtensions.x-field-extra-annotation}}
  {{{vendorExtensions.x-field-extra-annotation}}}
  {{/vendorExtensions.x-field-extra-annotation}}
  private {{#useBeanValidation}}@Valid {{/useBeanValidation}}{{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
  {{/vars}}
  {{#generateBuilders}}
  {{^additionalProperties}}

  protected {{classname}}({{classname}}Builder b) {
    {{#parent}}
    super(b);
    {{/parent}}
    {{#vars}}
    this.{{name}} = b.{{name}};
    {{/vars}}
  }

  public {{classname}}() {
  }
  {{/additionalProperties}}
  {{/generateBuilders}}

  {{#vars}}
  /**
   {{#description}}
   * {{.}}
   {{/description}}
   {{#minimum}}
   * minimum: {{.}}
   {{/minimum}}
   {{#maximum}}
   * maximum: {{.}}
   {{/maximum}}
   **/
  public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
    this.{{name}} = {{name}};
    return this;
  }

  {{#vendorExtensions.x-extra-annotation}}{{{vendorExtensions.x-extra-annotation}}}{{/vendorExtensions.x-extra-annotation}}{{#useSwaggerAnnotations}}
  @ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}"){{/useSwaggerAnnotations}}{{#useMicroProfileOpenAPIAnnotations}}
  @org.eclipse.microprofile.openapi.annotations.media.Schema({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}description = "{{{description}}}"){{/useMicroProfileOpenAPIAnnotations}}
  @JsonProperty("{{baseName}}")
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}}  public {{>beanValidatedType}} {{getter}}() {
    return {{name}};
  }

  @JsonProperty("{{baseName}}")
  {{#vendorExtensions.x-setter-extra-annotation}}{{{vendorExtensions.x-setter-extra-annotation}}}
  {{/vendorExtensions.x-setter-extra-annotation}}public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
    this.{{name}} = {{name}};
  }

  {{#isArray}}
  public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
    if (this.{{name}} == null) {
      this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}};
    }

    this.{{name}}.add({{name}}Item);
    return this;
  }

  public {{classname}} remove{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
    if ({{name}}Item != null && this.{{name}} != null) {
      this.{{name}}.remove({{name}}Item);
    }

    return this;
  }
  {{/isArray}}
  {{#isMap}}
  public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
    if (this.{{name}} == null) {
      this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}};
    }

    this.{{name}}.put(key, {{name}}Item);
    return this;
  }

  public {{classname}} remove{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
    if ({{name}}Item != null && this.{{name}} != null) {
      this.{{name}}.remove({{name}}Item);
    }

    return this;
  }
  {{/isMap}}
  {{/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 {{#vars}}{{#isByteArray}}Arrays{{/isByteArray}}{{^isByteArray}}Objects{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{^-last}} &&
        {{/-last}}{{/vars}}{{#parent}} &&
        super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}}
    return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};{{/hasVars}}
  }

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

  @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({{#isPassword}}"*"{{/isPassword}}{{^isPassword}}toIndentedString({{name}}){{/isPassword}}).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(Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }

{{#generateBuilders}}{{^additionalProperties}}
  public static {{classname}}Builder builder() {
    return new {{classname}}BuilderImpl();
  }

  private static final class {{classname}}BuilderImpl extends {{classname}}Builder<{{classname}}, {{classname}}BuilderImpl> {

    @Override
    protected {{classname}}BuilderImpl self() {
      return this;
    }

    @Override
    public {{classname}} build() {
      return new {{classname}}(this);
    }
  }

  public static abstract class {{classname}}Builder> {{#parent}}extends {{{.}}}Builder{{/parent}} {
    {{#vars}}
    private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
    {{/vars}}
  {{^parent}}
    protected abstract B self();

    public abstract C build();
    {{/parent}}

    {{#vars}}
    public B {{name}}({{{datatypeWithEnum}}} {{name}}) {
      this.{{name}} = {{name}};
      return self();
    }
    {{/vars}}
  }{{/additionalProperties}}{{/generateBuilders}}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy