UNPKG

@itwin/ecschema-metadata

Version:

ECObjects core concepts in typescript

89 lines 3.42 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module Metadata */ Object.defineProperty(exports, "__esModule", { value: true }); exports.MutablePropertyCategory = exports.PropertyCategory = void 0; const ECObjects_1 = require("../ECObjects"); const Exception_1 = require("../Exception"); const SchemaItem_1 = require("./SchemaItem"); /** * @public @preview */ class PropertyCategory extends SchemaItem_1.SchemaItem { schemaItemType = PropertyCategory.schemaItemType; /** @internal */ static get schemaItemType() { return ECObjects_1.SchemaItemType.PropertyCategory; } _priority; get priority() { return this._priority; } /** @internal */ constructor(schema, name) { super(schema, name); this._priority = 0; } /** * Save this PropertyCategory's properties to an object for serializing to JSON. * @param standalone Serialization includes only this object (as opposed to the full schema). * @param includeSchemaVersion Include the Schema's version information in the serialized object. */ toJSON(standalone = false, includeSchemaVersion = false) { const schemaJson = super.toJSON(standalone, includeSchemaVersion); schemaJson.priority = this.priority; return schemaJson; } /** @internal */ async toXml(schemaXml) { const itemElement = await super.toXml(schemaXml); itemElement.setAttribute("priority", this.priority.toString()); return itemElement; } fromJSONSync(propertyCategoryProps) { super.fromJSONSync(propertyCategoryProps); this._priority = propertyCategoryProps.priority; } async fromJSON(propertyCategoryProps) { this.fromJSONSync(propertyCategoryProps); } /** * Used for schema editing. * @internal */ setPriority(priority) { this._priority = priority; } /** * Type guard to check if the SchemaItem is of type PropertyCategory. * @param item The SchemaItem to check. * @returns True if the item is a PropertyCategory, false otherwise. */ static isPropertyCategory(item) { if (item && item.schemaItemType === ECObjects_1.SchemaItemType.PropertyCategory) return true; return false; } /** * Type assertion to check if the SchemaItem is of type PropertyCategory. * @param item The SchemaItem to check. * @returns The item cast to PropertyCategory if it is a PropertyCategory, undefined otherwise. * @internal */ static assertIsPropertyCategory(item) { if (!this.isPropertyCategory(item)) throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidSchemaItemType, `Expected '${ECObjects_1.SchemaItemType.PropertyCategory}' (PropertyCategory)`); } } exports.PropertyCategory = PropertyCategory; /** * @internal * An abstract class used for schema editing. */ class MutablePropertyCategory extends PropertyCategory { } exports.MutablePropertyCategory = MutablePropertyCategory; //# sourceMappingURL=PropertyCategory.js.map