UNPKG

@itwin/ecschema-metadata

Version:

ECObjects core concepts in typescript

107 lines 4.38 kB
/** @packageDocumentation * @module Metadata */ import { EnumerationProps } from "../Deserialization/JsonProps"; import { PrimitiveType, SchemaItemType } from "../ECObjects"; import { Schema } from "./Schema"; import { SchemaItem } from "./SchemaItem"; /** @public @preview */ export interface Enumerator<T> { readonly name: string; readonly value: T; readonly label?: string; readonly description?: string; } /** @public @preview */ export type AnyEnumerator = Enumerator<string | number>; /** * A Typescript class representation of an ECEnumeration. * @public @preview */ export declare class Enumeration extends SchemaItem { readonly schemaItemType: SchemaItemType; /** @internal */ static get schemaItemType(): SchemaItemType; private _type?; private _isStrict; private _enumerators; get enumerators(): ReadonlyArray<AnyEnumerator>; get type(): PrimitiveType.Integer | PrimitiveType.String | undefined; get isStrict(): boolean; /** @internal */ constructor(schema: Schema, name: string, primitiveType?: PrimitiveType.Integer | PrimitiveType.String); get isInt(): boolean; get isString(): boolean; /** * Gets an enumerator that matches the name provided. * @param name The ECName of the Enumerator to find. */ getEnumeratorByName(name: string): AnyEnumerator | undefined; /** * Gets an enumerator that matches the value provided. * @param value The value of the Enumerator to find. */ getEnumerator(value: string): Enumerator<string> | undefined; getEnumerator(value: number): Enumerator<number> | undefined; /** * Checks whether there already exists an enumerator with this name or this value * @param name The name of the enumerator we are trying to create * @param value The value of the enumerator we are trying to create * @internal */ private findDuplicateEnumerators; /** * Creates an Enumerator with the provided name and value as well as optional parameters label and description * @param name The name of the enumerator * @param value The value of the enumerator. The type of this value is dependent on the backing type of the this Enumeration. * @param label A localized display label that is used instead of the name in a GUI. * @param description A localized description for the enumerator. * @return AnyEnumerator object * @internal */ createEnumerator(name: string, value: string | number, label?: string, description?: string): AnyEnumerator; /** * Adds enumerator to list of enumerators on this Enumeration * @param enumerator The enumerator to add * @internal */ protected addEnumerator(enumerator: AnyEnumerator): void; /** * Save this Enumeration'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?: boolean, includeSchemaVersion?: boolean): EnumerationProps; /** @internal */ toXml(schemaXml: Document): Promise<Element>; fromJSONSync(enumerationProps: EnumerationProps): void; fromJSON(enumerationProps: EnumerationProps): Promise<void>; /** * @internal */ protected setIsStrict(isStrict: boolean): void; /** * Type guard to check if the SchemaItem is of type Enumeration. * @param item The SchemaItem to check. * @returns True if the item is an Enumeration, false otherwise. */ static isEnumeration(item?: SchemaItem): item is Enumeration; /** * Type assertion to check if the SchemaItem is of type Enumeration. * @param item The SchemaItem to check. * @returns The item cast to Enumeration if it is an Enumeration, undefined otherwise. * @internal */ static assertIsEnumeration(item?: SchemaItem): asserts item is Enumeration; } /** * An abstract class used for schema editing. * * @internal */ export declare abstract class MutableEnumeration extends Enumeration { abstract addEnumerator(enumerator: AnyEnumerator): void; abstract setIsStrict(isStrict: boolean): void; abstract setDisplayLabel(displayLabel: string): void; } //# sourceMappingURL=Enumeration.d.ts.map