UNPKG

@itwin/ecschema-metadata

Version:

ECObjects core concepts in typescript

84 lines 3.13 kB
/*--------------------------------------------------------------------------------------------- * 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 */ import { SchemaItemType } from "../ECObjects"; import { ECSchemaError, ECSchemaStatus } from "../Exception"; import { SchemaItem } from "./SchemaItem"; /** * @public @preview */ export class PropertyCategory extends SchemaItem { schemaItemType = PropertyCategory.schemaItemType; /** @internal */ static get schemaItemType() { return 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 === 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 ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.PropertyCategory}' (PropertyCategory)`); } } /** * @internal * An abstract class used for schema editing. */ export class MutablePropertyCategory extends PropertyCategory { } //# sourceMappingURL=PropertyCategory.js.map