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

custom_templates.pojo.mustache Maven / Gradle / Ivy

Go to download

The Okta Java SDK API .jar provides a Java API that your code can use to make calls to the Okta API. This .jar is the only compile-time dependency within the Okta SDK project that your code should depend on. Implementations of this API (implementation .jars) should be runtime dependencies only.

There is a newer version: 20.0.0
Show newest version
{{!
    Copyright (c) 2022-Present, Okta, Inc.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
}}
/**
* {{description}}{{^description}}{{classname}}{{/description}}{{#isDeprecated}}
    * @deprecated{{/isDeprecated}}
*/{{#isDeprecated}}
    @Deprecated{{/isDeprecated}}{{#description}}
    @ApiModel(description = "{{{.}}}"){{/description}}
{{#jackson}}
    @JsonPropertyOrder({
    {{#vars}}
        {{classname}}.JSON_PROPERTY_{{nameInSnakeCase}}{{^-last}},{{/-last}}
    {{/vars}}
    })
    {{#isClassnameSanitized}}
        @JsonTypeName("{{name}}")
    {{/isClassnameSanitized}}
{{/jackson}}
{{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
{{#vendorExtensions.x-class-extra-annotation}}
    {{{vendorExtensions.x-class-extra-annotation}}}
{{/vendorExtensions.x-class-extra-annotation}}
{{#additionalPropertiesType}}
public class {{classname}} {{#vendorExtensions.x-implements}}{{#-first}}implements {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{#-last}} {{/-last}}{{/vendorExtensions.x-implements}}{
{{/additionalPropertiesType}}
{{^additionalPropertiesType}}
public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtensions.x-implements}}{{#-first}}implements {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{#-last}} {{/-last}}{{/vendorExtensions.x-implements}}{
{{/additionalPropertiesType}}

{{#serializableModel}}
    private static final long serialVersionUID = 1L;

{{/serializableModel}}
{{#additionalPropertiesType}}
      public Map additionalProperties = new java.util.LinkedHashMap<>();

      public Map getAdditionalProperties() {
         return additionalProperties;
      }

      public void setAdditionalProperties(Map additionalProperties) {
         this.additionalProperties = additionalProperties;
      }
{{/additionalPropertiesType}}

{{#vars}}
    {{#isEnum}}
        {{^isContainer}}
            {{>modelInnerEnum}}
        {{/isContainer}}
        {{#isContainer}}
            {{#mostInnerItems}}
                {{>modelInnerEnum}}
            {{/mostInnerItems}}
        {{/isContainer}}
    {{/isEnum}}
    {{#gson}}
        public static final String SERIALIZED_NAME_{{nameInSnakeCase}} = "{{baseName}}";
    {{/gson}}
    {{#jackson}}
        public static final String JSON_PROPERTY_{{nameInSnakeCase}} = "{{baseName}}";
    {{/jackson}}
    {{#withXml}}
        {{#isXmlAttribute}}
            @XmlAttribute(name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
        {{/isXmlAttribute}}
        {{^isXmlAttribute}}
            {{^isContainer}}
                @XmlElement({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
            {{/isContainer}}
            {{#isContainer}}
                // Is a container wrapped={{isXmlWrapped}}
                {{#items}}
                    // items.name={{name}} items.baseName={{baseName}} items.xmlName={{xmlName}} items.xmlNamespace={{xmlNamespace}}
                    // items.example={{example}} items.type={{dataType}}
                    @XmlElement({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
                {{/items}}
                {{#isXmlWrapped}}
                    @XmlElementWrapper({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
                {{/isXmlWrapped}}
            {{/isContainer}}
        {{/isXmlAttribute}}
    {{/withXml}}
    {{#gson}}
        @SerializedName(SERIALIZED_NAME_{{nameInSnakeCase}})
    {{/gson}}
    {{#vendorExtensions.x-field-extra-annotation}}
        {{{vendorExtensions.x-field-extra-annotation}}}
    {{/vendorExtensions.x-field-extra-annotation}}
    {{#vendorExtensions.x-is-jackson-optional-nullable}}
        {{#isContainer}}
            private JsonNullable<{{{datatypeWithEnum}}}> {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>undefined();
        {{/isContainer}}
        {{^isContainer}}
            private JsonNullable<{{{datatypeWithEnum}}}> {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>{{#defaultValue}}of({{{.}}}){{/defaultValue}}{{^defaultValue}}undefined(){{/defaultValue}};
        {{/isContainer}}
    {{/vendorExtensions.x-is-jackson-optional-nullable}}
    {{^vendorExtensions.x-is-jackson-optional-nullable}}
        {{#isContainer}}
            private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/required}}{{^required}} = null{{/required}};
        {{/isContainer}}
        {{^isContainer}}
            {{#isDiscriminator}}protected{{/isDiscriminator}}{{^isDiscriminator}}private{{/isDiscriminator}} {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
        {{/isContainer}}
    {{/vendorExtensions.x-is-jackson-optional-nullable}}

{{/vars}}
public {{classname}}() { {{#parent}}{{#parcelableModel}}
    super();{{/parcelableModel}}{{/parent}}{{#gson}}{{#discriminator}}
    //this.{{{discriminatorName}}} = this.getClass().getSimpleName();{{/discriminator}}{{/gson}}
}{{#vendorExtensions.x-has-readonly-properties}}{{^withXml}}

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

    {{^isReadOnly}}
        public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
        {{#vendorExtensions.x-is-jackson-optional-nullable}}this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{name}});{{/vendorExtensions.x-is-jackson-optional-nullable}}
        {{^vendorExtensions.x-is-jackson-optional-nullable}}this.{{name}} = {{name}};{{/vendorExtensions.x-is-jackson-optional-nullable}}
        return this;
        }
        {{#isArray}}

            public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
            {{#vendorExtensions.x-is-jackson-optional-nullable}}
                if (this.{{name}} == null || !this.{{name}}.isPresent()) {
                this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}});
                }
                try {
                this.{{name}}.get().add({{name}}Item);
                } catch (java.util.NoSuchElementException e) {
                // this can never happen, as we make sure above that the value is present
                }
                return this;
            {{/vendorExtensions.x-is-jackson-optional-nullable}}
            {{^vendorExtensions.x-is-jackson-optional-nullable}}
                if (this.{{name}} == null) {
                this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}};
                }
                this.{{name}}.add({{name}}Item);
                return this;
            {{/vendorExtensions.x-is-jackson-optional-nullable}}
            }
        {{/isArray}}
        {{#isMap}}

            public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
            {{#vendorExtensions.x-is-jackson-optional-nullable}}
                if (this.{{name}} == null || !this.{{name}}.isPresent()) {
                this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
                }
                try {
                this.{{name}}.get().put(key, {{name}}Item);
                } catch (java.util.NoSuchElementException e) {
                // this can never happen, as we make sure above that the value is present
                }
                return this;
            {{/vendorExtensions.x-is-jackson-optional-nullable}}
            {{^vendorExtensions.x-is-jackson-optional-nullable}}
                {{^required}}
                    if (this.{{name}} == null) {
                    this.{{name}} = {{{defaultValue}}};
                    }
                {{/required}}
                this.{{name}}.put(key, {{name}}Item);
                return this;
            {{/vendorExtensions.x-is-jackson-optional-nullable}}
            }
        {{/isMap}}

    {{/isReadOnly}}
    /**
    {{#description}}
        * {{.}}
    {{/description}}
    {{^description}}
        * Get {{name}}
    {{/description}}
    {{#minimum}}
        * minimum: {{.}}
    {{/minimum}}
    {{#maximum}}
        * maximum: {{.}}
    {{/maximum}}
    * @return {{name}}
    {{#deprecated}}
        * @deprecated
    {{/deprecated}}
    **/
    {{#deprecated}}
        @Deprecated
    {{/deprecated}}
    {{#required}}
        {{#isNullable}}
            @javax.annotation.Nullable
        {{/isNullable}}
        {{^isNullable}}
            @javax.annotation.Nonnull
        {{/isNullable}}
    {{/required}}
    {{^required}}
        @javax.annotation.Nullable
    {{/required}}
    {{#jsonb}}
        @JsonbProperty("{{baseName}}")
    {{/jsonb}}
    {{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}}  @ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
    {{#vendorExtensions.x-extra-annotation}}
        {{{vendorExtensions.x-extra-annotation}}}
    {{/vendorExtensions.x-extra-annotation}}
    {{#vendorExtensions.x-is-jackson-optional-nullable}}
    {{!unannotated, Jackson would pick this up automatically and add it *in addition* to the _JsonNullable getter field}}
        @JsonIgnore
    {{/vendorExtensions.x-is-jackson-optional-nullable}}
    {{^vendorExtensions.x-is-jackson-optional-nullable}}{{#jackson}}{{> jackson_annotations}}{{/jackson}}{{/vendorExtensions.x-is-jackson-optional-nullable}}
    public {{{datatypeWithEnum}}} {{getter}}() {
    {{#vendorExtensions.x-is-jackson-optional-nullable}}
        {{#isReadOnly}}{{! A readonly attribute doesn't have setter => jackson will set null directly if explicitly returned by API, so make sure we have an empty JsonNullable}}
            if ({{name}} == null) {
            {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>{{#defaultValue}}of({{{.}}}){{/defaultValue}}{{^defaultValue}}undefined(){{/defaultValue}};
            }
        {{/isReadOnly}}
        return {{name}}.orElse(null);
    {{/vendorExtensions.x-is-jackson-optional-nullable}}
    {{^vendorExtensions.x-is-jackson-optional-nullable}}
        return {{name}};
    {{/vendorExtensions.x-is-jackson-optional-nullable}}
    }

    {{#vendorExtensions.x-is-jackson-optional-nullable}}
        {{> jackson_annotations}}
        public JsonNullable<{{{datatypeWithEnum}}}> {{getter}}_JsonNullable() {
        return {{name}};
        }
    {{/vendorExtensions.x-is-jackson-optional-nullable}}{{#vendorExtensions.x-is-jackson-optional-nullable}}
        @JsonProperty(JSON_PROPERTY_{{nameInSnakeCase}})
        {{#isReadOnly}}private{{/isReadOnly}}{{^isReadOnly}}public{{/isReadOnly}} void {{setter}}_JsonNullable(JsonNullable<{{{datatypeWithEnum}}}> {{name}}) {
        {{! For getters/setters that have name differing from attribute name, we must include setter (albeit private) for jackson to be able to set the attribute}}
        this.{{name}} = {{name}};
        }
    {{/vendorExtensions.x-is-jackson-optional-nullable}}

    {{^isReadOnly}}
        {{#vendorExtensions.x-setter-extra-annotation}}  {{{vendorExtensions.x-setter-extra-annotation}}}
        {{/vendorExtensions.x-setter-extra-annotation}}{{#jackson}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{> jackson_annotations}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{/jackson}}  public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
        {{#vendorExtensions.x-is-jackson-optional-nullable}}
            this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{name}});
        {{/vendorExtensions.x-is-jackson-optional-nullable}}
        {{^vendorExtensions.x-is-jackson-optional-nullable}}
            this.{{name}} = {{name}};
        {{/vendorExtensions.x-is-jackson-optional-nullable}}
        }
    {{/isReadOnly}}

{{/vars}}

@Override
public boolean equals(Object o) {
{{#useReflectionEqualsHashCode}}
    return EqualsBuilder.reflectionEquals(this, o, false, null, true);
{{/useReflectionEqualsHashCode}}
{{^useReflectionEqualsHashCode}}
    if (this == o) {
    return true;
    }
    if (o == null || getClass() != o.getClass()) {
    return false;
    }{{#hasVars}}
        {{classname}} {{classVarName}} = ({{classname}}) o;
        return {{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}equalsNullable(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#isByteArray}}Arrays{{/isByteArray}}{{^isByteArray}}Objects{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}} &&
        {{/-last}}{{/vars}};
        //{{#parent}} && super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}}
        {{/hasVars}}{{^hasVars}}
        return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};{{/hasVars}}
{{/useReflectionEqualsHashCode}}
}{{#vendorExtensions.x-jackson-optional-nullable-helpers}}

    private static  boolean equalsNullable(JsonNullable a, JsonNullable b) {
        return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
        }{{/vendorExtensions.x-jackson-optional-nullable-helpers}}

    @Override
    public int hashCode() {
{{#useReflectionEqualsHashCode}}
        return HashCodeBuilder.reflectionHashCode(this);
{{/useReflectionEqualsHashCode}}
{{^useReflectionEqualsHashCode}}
        return Objects.hash({{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}hashCodeNullable({{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}});
{{/useReflectionEqualsHashCode}}
    }{{#vendorExtensions.x-jackson-optional-nullable-helpers}}

        private static  int hashCodeNullable(JsonNullable a) {
        if (a == null) {
        return 1;
        }
        return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
        }{{/vendorExtensions.x-jackson-optional-nullable-helpers}}

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


{{#parcelableModel}}

        public void writeToParcel(Parcel out, int flags) {
    {{#model}}
        {{#isArray}}
                out.writeList(this);
        {{/isArray}}
        {{^isArray}}
            {{#parent}}
                    super.writeToParcel(out, flags);
            {{/parent}}
            {{#vars}}
                    out.writeValue({{name}});
            {{/vars}}
        {{/isArray}}
    {{/model}}
        }

    {{classname}}(Parcel in) {
    {{#isArray}}
            in.readTypedList(this, {{arrayModelType}}.CREATOR);
    {{/isArray}}
    {{^isArray}}
        {{#parent}}
                super(in);
        {{/parent}}
        {{#vars}}
            {{#isPrimitiveType}}
                {{name}} = ({{{datatypeWithEnum}}})in.readValue(null);
            {{/isPrimitiveType}}
            {{^isPrimitiveType}}
                {{name}} = ({{{datatypeWithEnum}}})in.readValue({{complexType}}.class.getClassLoader());
            {{/isPrimitiveType}}
        {{/vars}}
    {{/isArray}}
        }

        public int describeContents() {
        return 0;
        }

        public static final Parcelable.Creator<{{classname}}> CREATOR = new Parcelable.Creator<{{classname}}>() {
        public {{classname}} createFromParcel(Parcel in) {
    {{#model}}
        {{#isArray}}
            {{classname}} result = new {{classname}}();
                result.addAll(in.readArrayList({{arrayModelType}}.class.getClassLoader()));
                return result;
        {{/isArray}}
        {{^isArray}}
                return new {{classname}}(in);
        {{/isArray}}
    {{/model}}
        }
        public {{classname}}[] newArray(int size) {
        return new {{classname}}[size];
        }
        };
{{/parcelableModel}}
    }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy