ifc-expressions
Version:
Parsing and evaluation of IFC expressions
47 lines (46 loc) • 1.48 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SimpleType = void 0;
const IfcExpressionUtils_js_1 = require("../util/IfcExpressionUtils.js");
const Types_js_1 = require("./Types.js");
const TypeDisjunction_js_1 = require("./TypeDisjunction.js");
class SimpleType {
constructor(name, superType = Types_js_1.Type.ANY) {
this.superType = superType;
this.name = name;
}
getName() {
return this.name;
}
isSameTypeAs(other) {
return this === other || other.getName() === this.getName();
}
isSuperTypeOf(other) {
return other.isSubTypeOf(this);
}
isSubTypeOf(other) {
if (other instanceof TypeDisjunction_js_1.TypeDisjunction) {
return other.isSuperTypeOf(this);
}
if ((0, IfcExpressionUtils_js_1.isNullish)(this.superType)) {
return false;
}
if (this.superType.isSameTypeAs(other)) {
return true;
}
if (this.superType.isSameTypeAs(Types_js_1.Type.ANY)) {
return false;
}
return this.superType.isSubTypeOf(other);
}
overlapsWith(other) {
return (this.isSameTypeAs(other) ||
this.isSuperTypeOf(other) ||
this.isSubTypeOf(other));
}
isAssignableFrom(other) {
return this.isSameTypeAs(other) || this.isSuperTypeOf(other);
}
}
exports.SimpleType = SimpleType;
//# sourceMappingURL=SimpleType.js.map