cv-dialog-sdk
Version:
Catavolt Dialog Javascript API
72 lines (71 loc) • 1.99 kB
JavaScript
import { DialogProxyTools } from "./DialogProxyTools";
/**
*
*/
export class PropertyDefVisitor {
constructor(value) {
if (!value) {
throw new Error('PropertyDefVisitor -- null value exception');
}
if (typeof value === 'string') {
this._enclosedJsonObject = JSON.parse(value);
}
else {
this._enclosedJsonObject = value;
}
if (!DialogProxyTools.isPropertyDefModel(this._enclosedJsonObject)) {
throw new Error("Object passed to PropertyDefVisitor is not a PropertyDef");
}
}
// --- State Management Helpers --- //
// --- State Import/Export --- //
copyAsJsonObject() {
return JSON.parse(this.copyAsJsonString());
}
copyAsJsonString() {
return JSON.stringify(this.enclosedJsonObject());
}
enclosedJsonObject() {
return this._enclosedJsonObject;
}
// --- State Management --- //
canCauseSideEffects() {
return this.enclosedJsonObject().canCauseSideEffects;
}
contentType() {
return this.enclosedJsonObject().contentType;
}
displayLength() {
return this.enclosedJsonObject().displayLength;
}
format() {
return this.enclosedJsonObject().format;
}
length() {
return this.enclosedJsonObject().length;
}
propertyName() {
return this.enclosedJsonObject().propertyName;
}
propertyType() {
return this.enclosedJsonObject().propertyType;
}
scale() {
return this.enclosedJsonObject().scale;
}
semanticType() {
return this.enclosedJsonObject().semanticType;
}
type() {
return this.enclosedJsonObject().type;
}
upperCaseOnly() {
return this.enclosedJsonObject().upperCaseOnly;
}
writeAllowed() {
return this.enclosedJsonObject().writeAllowed;
}
writeEnabled() {
return this.enclosedJsonObject().writeEnabled;
}
}