cv-dialog-sdk
Version:
Catavolt Dialog Javascript API
32 lines (31 loc) • 920 B
JavaScript
import { DialogProxyTools } from "./DialogProxyTools";
/**
*
*/
export class AnnotationVisitor {
constructor(value) {
if (!value) {
throw new Error('AnnotationVisitor -- null value exception');
}
if (typeof value === 'string') {
this._enclosedJsonObject = JSON.parse(value);
}
else {
this._enclosedJsonObject = value;
}
if (!DialogProxyTools.isAnnotationModel(this._enclosedJsonObject)) {
throw new Error("Object passed to AnnotationVisitor is not an Annotation");
}
}
// --- State Management Helpers --- //
// --- State Import/Export --- //
copyAsJsonObject() {
return JSON.parse(this.copyAsJsonString());
}
copyAsJsonString() {
return JSON.stringify(this.enclosedJsonObject());
}
enclosedJsonObject() {
return this._enclosedJsonObject;
}
}