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 { ModelUtils } from '../util/ModelUtils';
import { NodeCompat } from '../../compat/NodeCompat';
import { Constants } from '../../core/Constants';
import { SimplifiedType } from './SimplifiedType';
/**
 * @author eric.wittmann@gmail.com
 * @class
 * @extends SimplifiedType
 */
var SimplifiedPropertyType = /** @class */ (function (_super) {
    __extends(SimplifiedPropertyType, _super);
    function SimplifiedPropertyType() {
        var _this = _super.call(this) || this;
        if (_this.required === undefined)
            _this.required = null;
        return _this;
    }
    SimplifiedPropertyType.fromPropertySchema = function (schema) {
        var s = schema;
        var rval = new SimplifiedPropertyType();
        var propName = schema.getPropertyName();
        var required = NodeCompat.getProperty(s.parent(), Constants.PROP_REQUIRED);
        var st = SimplifiedType.fromSchema(schema);
        rval.type = st.type;
        rval.enum_ = st.enum_;
        rval.of = st.of;
        rval.as = st.as;
        rval.required = false;
        if (ModelUtils.isDefined(required) && /* size */ required.length > 0 && required.indexOf(propName) !== -1) {
            rval.required = true;
        }
        return rval;
    };
    return SimplifiedPropertyType;
}(SimplifiedType));
export { SimplifiedPropertyType };
SimplifiedPropertyType["__class"] = "io.apicurio.datamodels.cmd.models.SimplifiedPropertyType";
//# sourceMappingURL=SimplifiedPropertyType.js.map