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

java-helidon.common.pojo.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
{{#jsonb}}
import java.lang.reflect.Type;
import {{rootJavaEEPackage}}.json.bind.annotation.JsonbTypeDeserializer;
import {{rootJavaEEPackage}}.json.bind.annotation.JsonbTypeSerializer;
import {{rootJavaEEPackage}}.json.bind.serializer.DeserializationContext;
import {{rootJavaEEPackage}}.json.bind.serializer.JsonbDeserializer;
import {{rootJavaEEPackage}}.json.bind.serializer.JsonbSerializer;
import {{rootJavaEEPackage}}.json.bind.serializer.SerializationContext;
import {{rootJavaEEPackage}}.json.stream.JsonGenerator;
import {{rootJavaEEPackage}}.json.stream.JsonParser;
import {{rootJavaEEPackage}}.json.bind.annotation.JsonbProperty;
{{#vendorExtensions.x-has-readonly-properties}}
import {{rootJavaEEPackage}}.json.bind.annotation.JsonbCreator;
{{/vendorExtensions.x-has-readonly-properties}}
{{/jsonb}}

{{#description}}
/**
 * {{{.}}}
 */{{/description}}
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}}
    private {{{datatypeWithEnum}}} {{{name}}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/vars}}

    /**
     * Default constructor.
     */
    public {{classname}}() {
    // JSON-B / Jackson
    }

    /**
     * Create {{classname}}.
     *
{{#vars}}
     * @param {{name}} {{description}}{{^description}}{{name}}{{/description}}
{{/vars}}
     */
    public {{classname}}(
{{#vars}}
        {{{datatypeWithEnum}}} {{name}}{{^-last}}, {{/-last}}
{{/vars}}
    ) {
{{#vars}}
        this.{{name}} = {{name}};
{{/vars}}
    }

{{#vars}}{{#vendorExtensions.x-has-readonly-properties}}{{#jsonb}}
    @JsonbCreator
    public {{classname}}(
    {{#readOnlyVars}}
        @JsonbProperty("{{baseName}}") {{{datatypeWithEnum}}} {{name}}{{^-last}}, {{/-last}}
    {{/readOnlyVars}}
    ) {
    {{#readOnlyVars}}
        this.{{name}} = {{name}};
    {{/readOnlyVars}}
    }{{/jsonb}}{{/vendorExtensions.x-has-readonly-properties}}

    /**
    {{#description}}
     * {{{.}}}
    {{/description}}
    {{^description}}
     * Get {{name}}
    {{/description}}
    {{#minimum}}
     * minimum: {{.}}
    {{/minimum}}
    {{#maximum}}
     * maximum: {{.}}
    {{/maximum}}
     * @return {{name}}
     */
    public {{{datatypeWithEnum}}} {{getter}}() {
        return {{name}};
    }

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

    /**
      * Create a string representation of this pojo.
    **/
    @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 static String toIndentedString(Object o) {
        if (o == null) {
          return "null";
        }
        return o.toString().replace("\n", "\n    ");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy