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

OktaJavaImpl.modelImpl.mustache Maven / Gradle / Ivy

{{!
    Copyright 2017 Okta

    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.
}}
import com.okta.sdk.impl.resource.AbstractInstanceResource;
import com.okta.sdk.impl.resource.AbstractResource;
import com.okta.sdk.impl.resource.Property;
import com.okta.sdk.impl.resource.ResourceReference;
import com.okta.sdk.impl.ds.InternalDataStore;
import com.okta.sdk.impl.http.QueryString;

{{! TODO: add these programatically when needed }}
import com.okta.sdk.impl.resource.BooleanProperty;
import com.okta.sdk.impl.resource.IntegerProperty;
import com.okta.sdk.impl.resource.DoubleProperty;
import com.okta.sdk.impl.resource.StringProperty;
import com.okta.sdk.impl.resource.CharacterArrayProperty;
import com.okta.sdk.impl.resource.ListProperty;
import com.okta.sdk.impl.resource.EnumListProperty;
import com.okta.sdk.impl.resource.ResourceListProperty;
import com.okta.sdk.impl.resource.DateProperty;
import com.okta.sdk.impl.resource.EnumProperty;
import com.okta.sdk.impl.resource.MapProperty;
import com.okta.sdk.impl.resource.DefaultVoidResource;
import com.okta.sdk.resource.VoidResource;
{{#vendorExtensions.top-level}}
import com.okta.sdk.resource.Resource;
{{/vendorExtensions.top-level}}
import java.util.Map;

import static com.okta.commons.lang.Assert.notNull;
import static com.okta.commons.lang.Assert.hasText;

{{#models}}{{#model}}
/**
 * {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
 */
@javax.annotation.Generated(
        value = "{{generatorClass}}",
        date  = "{{generatedDate}}")
public class Default{{classname}} extends {{#parent}}{{.}}{{/parent}}{{^parent}}{{#vendorExtensions.top-level}}AbstractInstanceResource<{{classname}}>{{/vendorExtensions.top-level}}{{^vendorExtensions.top-level}}AbstractResource{{/vendorExtensions.top-level}}{{/parent}} implements {{classname}} {

{{#vars}}
    private final static {{vendorExtensions.propertyType}}{{#vendorExtensions.itemType}}<{{{vendorExtensions.itemType}}}>{{/vendorExtensions.itemType}} {{name}}Property = new {{vendorExtensions.propertyType}}("{{baseName}}"{{vendorExtensions.constructorTypeExtra}});
{{/vars}}

    private final static Map PROPERTY_DESCRIPTORS = createPropertyDescriptorMap({{#vars}}{{name}}Property{{^-last}}, {{/-last}}{{/vars}});

    public Default{{classname}}(InternalDataStore dataStore) {
        super(dataStore);{{#vendorExtensions.defaultSetter}}
        setProperty("{{key}}", "{{value}}");{{/vendorExtensions.defaultSetter}}
    }

    public Default{{classname}}(InternalDataStore dataStore, Map properties) {
        super(dataStore, properties);
    }

    @Override
    public Map getPropertyDescriptors() {
        return PROPERTY_DESCRIPTORS;
    }

{{#vendorExtensions.top-level}}
    @Override
    public Class getResourceClass() {
        return {{#vendorExtensions.discriminatorRoot}}{{.}}{{/vendorExtensions.discriminatorRoot}}{{^vendorExtensions.discriminatorRoot}}{{classname}}{{/vendorExtensions.discriminatorRoot}}.class;
    }
{{/vendorExtensions.top-level}}
{{#vars}}

    public {{{datatypeWithEnum}}} {{getter}}() {
        return {{#vendorExtensions.forceCast}}({{{datatypeWithEnum}}}){{/vendorExtensions.forceCast}} {{vendorExtensions.propertyTypeMethod}}({{name}}Property);
    }
    {{^isReadOnly}}

    public {{classname}} {{setter}}({{{datatypeWithEnum}}} {{name}}) {
        setProperty({{name}}Property, {{name}});
        return this;
    }
    {{/isReadOnly}}
{{/vars}}
{{#vendorExtensions.operations}}{{#.}}

    /**
    * {{summary}}
    * {{notes}}
    {{#vendorExtensions.allParams}}
    * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
    {{/vendorExtensions.allParams}}
    {{#returnType}}
    * @return {{returnType}}
    {{/returnType}}
    */
    @Override
    @javax.annotation.Generated(
          value    = "{{generatorClass}}",
          date     = "{{generatedDate}}",
          comments = "{{httpMethod}} - {{path}}")
    public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{#vendorExtensions.alias}}{{vendorExtensions.alias}}{{/vendorExtensions.alias}}{{^vendorExtensions.alias}}{{operationId}}{{/vendorExtensions.alias}}({{#vendorExtensions.allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.allParams}}) {

{{#vendorExtensions.fromModelPathParams}}{{#.}}        {{{dataType}}} {{paramName}} = {{vendorExtensions.fromModel.getter}}();{{/.}}{{/vendorExtensions.fromModelPathParams}}
    {{#vendorExtensions.hasPathParents}}
        Map pathArgs = getParamsFromHref("{{path}}");
    {{#vendorExtensions.pathParents}}
        String {{.}} = pathArgs.get("{{.}}");
    {{/vendorExtensions.pathParents}}
    {{/vendorExtensions.hasPathParents}}
{{>queryPartial}}
{{#vendorExtensions.isGet}}
{{>apiMethodGet}}
{{/vendorExtensions.isGet}}
{{#vendorExtensions.isPut}}
{{>apiMethodPut}}
{{/vendorExtensions.isPut}}
{{#vendorExtensions.isPost}}
{{>apiMethodPostResource}}
{{/vendorExtensions.isPost}}
{{#vendorExtensions.isDelete}}
{{>apiMethodDelete}}
{{/vendorExtensions.isDelete}}
    }
{{#vendorExtensions.hasOptional}}

    /**
    * {{summary}}
    * {{notes}}
    {{#vendorExtensions.nonOptionalParams}}
    * @param {{paramName}} {{description}} (required)
    {{/vendorExtensions.nonOptionalParams}}
    {{#returnType}}
    * @return {{returnType}}
    {{/returnType}}
    */
    @Override
    @javax.annotation.Generated(
          value    = "{{generatorClass}}",
          date     = "{{generatedDate}}",
          comments = "{{httpMethod}} - {{path}}")
    public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{#vendorExtensions.alias}}{{vendorExtensions.alias}}{{/vendorExtensions.alias}}{{^vendorExtensions.alias}}{{operationId}}{{/vendorExtensions.alias}}({{#vendorExtensions.nonOptionalParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.nonOptionalParams}}) {

{{#vendorExtensions.fromModelPathParams}}{{#.}}        {{{dataType}}} {{paramName}} = {{vendorExtensions.fromModel.getter}}();{{/.}}{{/vendorExtensions.fromModelPathParams}}
    {{#vendorExtensions.hasPathParents}}
        Map pathArgs = getParamsFromHref("{{path}}");
        {{#vendorExtensions.pathParents}}
        String {{.}} = pathArgs.get("{{.}}");
        {{/vendorExtensions.pathParents}}
    {{/vendorExtensions.hasPathParents}}
{{>queryPartialRequired}}
{{#vendorExtensions.isGet}}
{{>apiMethodGet}}
{{/vendorExtensions.isGet}}
{{#vendorExtensions.isPut}}
{{>apiMethodPut}}
{{/vendorExtensions.isPut}}
{{#vendorExtensions.isPost}}
    {{#vendorExtensions.optionalBody}}
{{>apiMethodPostNoBody}}
    {{/vendorExtensions.optionalBody}}
    {{^vendorExtensions.optionalBody}}
{{>apiMethodPostResource}}
    {{/vendorExtensions.optionalBody}}
{{/vendorExtensions.isPost}}
{{#vendorExtensions.isDelete}}
{{>apiMethodDelete}}
{{/vendorExtensions.isDelete}}
     }
{{/vendorExtensions.hasOptional}}

{{#vendorExtensions.hasBackwardsCompatibleParams}}
    /**
    * {{summary}}
    * {{notes}}
    {{#vendorExtensions.onlyBackwardsCompatibleParams}}
    * @param {{paramName}} {{description}} (required)
    {{/vendorExtensions.onlyBackwardsCompatibleParams}}
    {{#returnType}}
    * @return {{returnType}}
    {{/returnType}}
    */
    @Override
    @javax.annotation.Generated(
            value    = "{{generatorClass}}",
            date     = "{{generatedDate}}",
            comments = "{{httpMethod}} - {{path}}")
    public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{#vendorExtensions.alias}}{{vendorExtensions.alias}}{{/vendorExtensions.alias}}{{^vendorExtensions.alias}}{{operationId}}{{/vendorExtensions.alias}}({{#vendorExtensions.onlyBackwardsCompatibleParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.onlyBackwardsCompatibleParams}}) {

    {{#vendorExtensions.fromModelPathParams}}{{#.}}        {{{dataType}}} {{paramName}} = {{vendorExtensions.fromModel.getter}}();{{/.}}{{/vendorExtensions.fromModelPathParams}}
    {{#vendorExtensions.hasPathParents}}
        Map pathArgs = getParamsFromHref("{{path}}");
        {{#vendorExtensions.pathParents}}
        String {{.}} = pathArgs.get("{{.}}");
        {{/vendorExtensions.pathParents}}
    {{/vendorExtensions.hasPathParents}}
{{>queryPartialBackwardsCompat}}
{{#vendorExtensions.isGet}}
{{>apiMethodGet}}
{{/vendorExtensions.isGet}}
{{#vendorExtensions.isPut}}
{{>apiMethodPut}}
{{/vendorExtensions.isPut}}
{{#vendorExtensions.isPost}}
{{>apiMethodPostClient}}
{{/vendorExtensions.isPost}}
{{#vendorExtensions.isDelete}}
{{>apiMethodDelete}}
{{/vendorExtensions.isDelete}}
    }
{{/vendorExtensions.hasBackwardsCompatibleParams}}

{{/.}}
{{/vendorExtensions.operations}}
{{#vendorExtensions.optionalClassnamePartial}}// optional class specific partial{{/vendorExtensions.optionalClassnamePartial}}
{{/model}}
{{/models}}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy