/*
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for
 * license information.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 * Changes may cause incorrect behavior and will be lost if the code is
 * regenerated.
 */

'use strict';

/**
 * This is used to express the source of an input schema mapping for a single
 * target field
 * in the Event Grid Event schema. This is currently used in the mappings for
 * the 'subject',
 * 'eventtype' and 'dataversion' properties. This represents a field in the
 * input event schema
 * along with a default value to be used, and at least one of these two
 * properties should be provided.
 *
 */
class JsonFieldWithDefault {
  /**
   * Create a JsonFieldWithDefault.
   * @property {string} [sourceField] Name of a field in the input event schema
   * that's to be used as the source of a mapping.
   * @property {string} [defaultValue] The default value to be used for mapping
   * when a SourceField is not provided or if there's no property with the
   * specified name in the published JSON event payload.
   */
  constructor() {
  }

  /**
   * Defines the metadata of JsonFieldWithDefault
   *
   * @returns {object} metadata of JsonFieldWithDefault
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'JsonFieldWithDefault',
      type: {
        name: 'Composite',
        className: 'JsonFieldWithDefault',
        modelProperties: {
          sourceField: {
            required: false,
            serializedName: 'sourceField',
            type: {
              name: 'String'
            }
          },
          defaultValue: {
            required: false,
            serializedName: 'defaultValue',
            type: {
              name: 'String'
            }
          }
        }
      }
    };
  }
}

module.exports = JsonFieldWithDefault;
