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

handlebars.javascript.es6.partial_model_generic.mustache Maven / Gradle / Ivy

There is a newer version: 1.0.54
Show newest version
{{#emitJSDoc}}
/**
 * The {{classname}} model module.
 * @module {{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}
 * @version {{projectVersion}}
 */
{{/emitJSDoc}}
export default class {{classname}} {{#parentModel}}extends {{classname}} {{/parentModel}}{{#parent}}{{^parentModel}}{{#vendorExtensions.x-isArray}}extends Array {{/vendorExtensions.x-isArray}}{{/parentModel}}{{/parent}}{
{{#emitJSDoc}}
  /**
   * Constructs a new {{classname}}.{{#description}}
   * {{description}}{{/description}}
   * @alias module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}
   * @class{{#useInheritance}}{{#parent}}
   * @extends {{#parentModel}}module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}{{/parentModel}}{{^parentModel}}{{#vendorExtensions.x-isArray}}Array{{/vendorExtensions.x-isArray}}{{#vendorExtensions.x-isMap}}Object{{/vendorExtensions.x-isMap}}{{/parentModel}}{{/parent}}{{#interfaces}}
   * @implements module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{.}}{{/interfaces}}{{/useInheritance}}{{#vendorExtensions.x-all-required}}
   * @param {{name}} {{braces "left"}}{{&vendorExtensions.x-jsdoc-type}}{{braces "right"}} {{#description}}{{{description}}}{{/description}}{{/vendorExtensions.x-all-required}}
   */
{{/emitJSDoc}}
  constructor({{#vendorExtensions.x-all-required}}{{name}}{{^@last}}, {{/@last}}{{/vendorExtensions.x-all-required}}) {
{{#parentModel}}
    super({{#vendorExtensions.x-all-required}}{{name}}{{^@last}}, {{/@last}}{{/vendorExtensions.x-all-required}});
{{/parentModel}}
{{#parent}}
  {{^parentModel}}
    {{#vendorExtensions.x-isArray}}
    super();
    {{/vendorExtensions.x-isArray}}
  {{/parentModel}}
{{/parent}}
{{#vars}}
  {{#required}}
    this.{{name}} = {{name}};
  {{/required}}
{{/vars}}
  }

{{#emitJSDoc}}
  /**
   * Constructs a {{classname}} from a plain JavaScript object, optionally creating a new instance.
   * Copies all relevant properties from data to obj if supplied or a new instance if not.
   * @param {Object} data The plain JavaScript object bearing properties of interest.
   * @param {{braces "left"}}module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}{{braces "right"}} obj Optional instance to populate.
   * @return {{braces "left"}}module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}{{braces "right"}} The populated {{classname}} instance.
   */
{{/emitJSDoc}}
  static constructFromObject(data, obj) {
    if (data){{! TODO: support polymorphism: discriminator property on data determines class to instantiate.}} {
      obj = obj || new {{classname}}();
{{#parent}}
  {{^parentModel}}
      ApiClient.constructFromObject(data, obj, '{{vendorExtensions.x-itemType}}');
  {{/parentModel}}
{{/parent}}
{{#useInheritance}}
  {{#parentModel}}
      {{classname}}.constructFromObject(data, obj);
  {{/parentModel}}
  {{#interfaces}}
      {{.}}.constructFromObject(data, obj);
  {{/interfaces}}
{{/useInheritance}}
{{#vars}}
      if (data.hasOwnProperty('{{baseName}}'))
        obj.{{name}}{{{defaultValueWithParam}}}
{{/vars}}
    }
    return obj;
  }
{{#emitModelMethods}}

  {{#vars}}
    {{#emitJSDoc}}
  /**{{#description}}
   * Returns {{{description}}}{{/description}}{{#minimum}}
   * minimum: {{minimum}}{{/minimum}}{{#maximum}}
   * maximum: {{maximum}}{{/maximum}}
   * @return {{braces "left"}}{{&vendorExtensions.x-jsdoc-type}}{{braces "right"}}
   */
    {{/emitJSDoc}}
  {{getter}}() {
    return this.{{name}};
  }

    {{#emitJSDoc}}
  /**{{#description}}
   * Sets {{{description}}}{{/description}}
   * @param {{braces "left"}}{{&vendorExtensions.x-jsdoc-type}}{{braces "right"}} {{name}}{{#description}} {{{description}}}{{/description}}
   */
    {{/emitJSDoc}}
  {{setter}}({{name}}) {
    this.{{name}} = {{name}};
  }

  {{/vars}}
{{/emitModelMethods}}
}
{{#hasVars}}

  {{#vars}}
    {{#isEnum}}
      {{^isContainer}}
{{>partial_model_inner_enum}}
      {{/isContainer}}
    {{/isEnum}}
    {{#items.isEnum}}
      {{#items}}
        {{^isContainer}}
{{>partial_model_inner_enum}}
        {{/isContainer}}
      {{/items}}
    {{/items.isEnum}}
    {{#emitJSDoc}}
/**{{#description}}
 * {{{description}}}{{/description}}
 * @member {{braces "left"}}{{&vendorExtensions.x-jsdoc-type}}{{braces "right"}} {{name}}{{#defaultValue}}
 * @default {{{defaultValue}}}{{/defaultValue}}
 */
    {{/emitJSDoc}}
{{classname}}.prototype.{{name}} = {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}undefined{{/defaultValue}};

  {{/vars}}
{{/hasVars}}
{{#useInheritance}}
  {{#interfaceModels}}
// Implement {{classname}} interface:
    {{#allVars}}
      {{#emitJSDoc}}
/**{{#description}}
 * {{{description}}}{{/description}}
 * @member {{braces "left"}}{{&vendorExtensions.x-jsdoc-type}}{{braces "right"}} {{name}}{{#defaultValue}}
 * @default {{{defaultValue}}}{{/defaultValue}}
 */
      {{/emitJSDoc}}
{{classname}}.prototype.{{name}} = {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}undefined{{/defaultValue}};

    {{/allVars}}
  {{/interfaceModels}}
{{/useInheritance}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy