import { VisitorUtil } from '../../core/util/VisitorUtil';
/**
 * @author eric.wittmann@gmail.com
 * @class
 */
var SimplifiedTypeUtil = /** @class */ (function () {
    function SimplifiedTypeUtil() {
    }
    SimplifiedTypeUtil.setSimplifiedType = function (node, type) {
        node.$ref = null;
        node.type = null;
        node.enum_ = null;
        node.format = null;
        node.items = null;
        if (type.isSimpleType()) {
            node.type = type.type;
            node.format = type.as;
        }
        if (type.isFileType()) {
            node.type = type.type;
        }
        if (type.isEnum()) {
            node.enum_ = ([]);
            type.enum_.forEach(function (v) {
                /* add */ (node.enum_.push(/* valueOf */ new String(v).toString()) > 0);
            });
        }
        if (type.isRef()) {
            node.$ref = type.type;
        }
        if (type.isArray()) {
            node.type = "array";
            var viz = new SetItemsTypeVisitor(type);
            VisitorUtil.visitNode(node, viz);
        }
    };
    SimplifiedTypeUtil.setSimplifiedTypeOnParam = function (node, type) {
        node.$ref = null;
        node.type = null;
        node.enum_ = null;
        node.format = null;
        node.items = null;
        if (type.isSimpleType()) {
            node.type = type.type;
            node.format = type.as;
        }
        if (type.isFileType()) {
            node.type = type.type;
        }
        if (type.isEnum()) {
            node.enum_ = ([]);
            type.enum_.forEach(function (v) {
                /* add */ (node.enum_.push(/* valueOf */ new String(v).toString()) > 0);
            });
        }
        if (type.isRef()) {
            node.$ref = type.type;
        }
        if (type.isArray()) {
            node.type = "array";
            var viz = new SetItemsTypeVisitor(type);
            VisitorUtil.visitNode(node, viz);
        }
    };
    return SimplifiedTypeUtil;
}());
export { SimplifiedTypeUtil };
SimplifiedTypeUtil["__class"] = "io.apicurio.datamodels.cmd.util.SimplifiedTypeUtil";
import { SetItemsTypeVisitor } from './SetItemsTypeVisitor';
//# sourceMappingURL=SimplifiedTypeUtil.js.map