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

io.github.itroadlabs.apicross.springmvc.templates.dataModelPropertyGetterAndSetter.hbs Maven / Gradle / Ivy

The newest version!
{{!-- ObjectDataModelProperty --}}
{{#if (and optional generatorOpts.useJsonNullable)}}
    {{#unless writeOnly}}
        {{#if deprecated}}@Deprecated{{/if}}
        @JsonGetter("{{{name}}}")
        protected JsonNullable< {{#with type}}{{> typeWithoutListConstraints}}{{/with}} > {{resolvedName}}Json() {
        return this.{{resolvedName}};
        }
    {{/unless}}

    {{> documentation }}
    {{#if nullable}}@Nullable{{/if}}
    @JsonIgnore
    {{#if deprecated}}@Deprecated{{/if}}
    public {{#with type}}{{> typeWithoutListConstraints}}{{/with}} get{{capitalizeFirst resolvedName}}() throws NoSuchElementException {
    return this.{{resolvedName}}.get();
    }

    {{> documentation }}
    {{#if nullable}}@Nullable{{/if}}
    @JsonIgnore
    {{#if deprecated}}@Deprecated{{/if}}
    public {{#with type}}{{> typeWithoutListConstraints}}{{/with}} get{{capitalizeFirst resolvedName}}OrElse({{#with type}}{{> typeWithoutListConstraints}}{{/with}} defaultValue) {
    return this.{{resolvedName}}.isPresent()? this.{{resolvedName}}.get() : defaultValue;
    }

    @JsonIgnore
    {{#if deprecated}}@Deprecated{{/if}}
    public boolean is{{capitalizeFirst resolvedName}}Present() {
    return this.{{resolvedName}}.isPresent();
    }

    public void if{{capitalizeFirst resolvedName}}Present(Consumer<{{#with type}}{{> typeWithoutListConstraints}}{{/with}}> consumer) {
    if(this.{{resolvedName}}.isPresent()) { consumer.accept(this.{{resolvedName}}.get()); }
    }

{{else}}
    {{> documentation }}
    {{#if deprecated}}@Deprecated{{/if}}
    {{#if writeOnly}}
        @JsonIgnore
    {{else}}
        @JsonGetter("{{{name}}}")
    {{/if}}
    public {{#with type}}{{> type}}{{/with}} get{{capitalizeFirst resolvedName}}() {
    return this.{{resolvedName}};
    }
{{/if}}

{{!-- Setters --}}
{{#if deprecated}}@Deprecated{{/if}}
{{#if readOnly}}
    @JsonIgnore
{{else}}
    @JsonSetter("{{{name}}}")
{{/if}}
public void set{{capitalizeFirst resolvedName}}({{#unless nullable}}@Nonnull{{/unless}} {{#with type}}{{> typeWithoutListConstraints}}{{/with}} value) {
this.$specifiedProperties.add("{{name}}");
this.{{resolvedName}} = {{#if (and optional generatorOpts.useJsonNullable)}}JsonNullable.of(value){{else}}value{{/if}};
}

{{#if deprecated}}@Deprecated{{/if}}
public {{../typeName}} with{{capitalizeFirst resolvedName}}({{#unless nullable}}@Nonnull{{/unless}} {{#with type}}{{> typeWithoutListConstraints}}{{/with}} value) {
this.$specifiedProperties.add("{{name}}");
this.{{resolvedName}} = {{#if (and optional generatorOpts.useJsonNullable)}}JsonNullable.of(value){{else}}value{{/if}};
return this;
}

{{#unless nullable}}
    {{#if deprecated}}@Deprecated{{/if}}
    public  {{../typeName}} with{{capitalizeFirst resolvedName}}IfNotNull({{#with type}}{{> typeWithoutListConstraints}}{{/with}} value) {
    if(value != null) {
    this.$specifiedProperties.add("{{name}}");
    this.{{resolvedName}} = {{#if (and optional generatorOpts.useJsonNullable)}}JsonNullable.of(value){{else}}value{{/if}};
    }
    return this;
    }
{{/unless}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy