var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/* Generated from Java with JSweet 2.3.7 - http://www.jsweet.org */
import { Library } from '../../Library';
import { AbstractCommand } from '../AbstractCommand';
import { ModelUtils } from '../util/ModelUtils';
import { NodeCompat } from '../../compat/NodeCompat';
import { DocumentType } from '../../core/models/DocumentType';
/**
 * @author eric.wittmann@gmail.com
 * @class
 * @extends AbstractCommand
 */
var AbstractSchemaInhCommand = /** @class */ (function (_super) {
    __extends(AbstractSchemaInhCommand, _super);
    function AbstractSchemaInhCommand() {
        return _super.call(this) || this;
    }
    /**
     * Determines the current inheritance type for the given schema.
     * @param {OasSchema} schema
     * @return {string}
     */
    AbstractSchemaInhCommand.getInheritanceType = function (schema) {
        if (ModelUtils.isDefined(schema.allOf)) {
            return AbstractSchemaInhCommand.TYPE_ALL_OF;
        }
        if (schema.ownerDocument().getDocumentType() === DocumentType.openapi3) {
            var schema30 = schema;
            if (ModelUtils.isDefined(schema30.anyOf)) {
                return AbstractSchemaInhCommand.TYPE_ANY_OF;
            }
            if (ModelUtils.isDefined(schema30.oneOf)) {
                return AbstractSchemaInhCommand.TYPE_ONE_OF;
            }
        }
        return AbstractSchemaInhCommand.TYPE_NONE;
    };
    /**
     * Creates a schema of a particular type (allOf, anyOf, etc).
     * @param {OasSchema} parentSchema
     * @param {string} inheritanceType
     * @return {OasSchema}
     */
    AbstractSchemaInhCommand.prototype.createSchema = function (parentSchema, inheritanceType) {
        if (NodeCompat.equals(AbstractSchemaInhCommand.TYPE_ALL_OF, inheritanceType)) {
            return parentSchema.createAllOfSchema();
        }
        if (NodeCompat.equals(AbstractSchemaInhCommand.TYPE_ANY_OF, inheritanceType)) {
            var schema30 = parentSchema;
            return schema30.createAnyOfSchema();
        }
        if (NodeCompat.equals(AbstractSchemaInhCommand.TYPE_ONE_OF, inheritanceType)) {
            var schema30 = parentSchema;
            return schema30.createOneOfSchema();
        }
        return parentSchema.createAllOfSchema();
    };
    /**
     * Copies the given list of schemas to the appropriate property on the model
     * @param {*[]} schemas
     * @param {OasSchema} targetSchema
     * @param {string} inheritanceType
     */
    AbstractSchemaInhCommand.prototype.copySchemaJsTo = function (schemas, targetSchema, inheritanceType) {
        if (NodeCompat.equals(AbstractSchemaInhCommand.TYPE_ALL_OF, inheritanceType)) {
            schemas.forEach(function (ser) {
                targetSchema.addAllOfSchema(Library.readNode(ser, targetSchema.createAllOfSchema()));
            });
        }
        if (NodeCompat.equals(AbstractSchemaInhCommand.TYPE_ANY_OF, inheritanceType)) {
            var targetSchema30 = targetSchema;
            schemas.forEach((function (targetSchema30) {
                return function (ser) {
                    targetSchema30.addAnyOfSchema(Library.readNode(ser, targetSchema30.createAnyOfSchema()));
                };
            })(targetSchema30));
        }
        if (NodeCompat.equals(AbstractSchemaInhCommand.TYPE_ONE_OF, inheritanceType)) {
            var targetSchema30 = targetSchema;
            schemas.forEach((function (targetSchema30) {
                return function (ser) {
                    targetSchema30.addOneOfSchema(Library.readNode(ser, targetSchema30.createOneOfSchema()));
                };
            })(targetSchema30));
        }
    };
    AbstractSchemaInhCommand.TYPE_NONE = "none";
    AbstractSchemaInhCommand.TYPE_ALL_OF = "allOf";
    AbstractSchemaInhCommand.TYPE_ONE_OF = "oneOf";
    AbstractSchemaInhCommand.TYPE_ANY_OF = "anyOf";
    return AbstractSchemaInhCommand;
}(AbstractCommand));
export { AbstractSchemaInhCommand };
AbstractSchemaInhCommand["__class"] = "io.apicurio.datamodels.cmd.commands.AbstractSchemaInhCommand";
AbstractSchemaInhCommand["__interfaces"] = ["io.apicurio.datamodels.cmd.ICommand"];
//# sourceMappingURL=AbstractSchemaInhCommand.js.map