/*! * Copyright 2020 Ron Buckton * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import type { GraphSchema } from "./graphSchema"; import type { DataTypeNameLike } from "./dataTypeNameLike"; import { BaseCollection } from "./baseCollection"; import { DataType, DataTypeOptions } from "./dataType"; import { EventSubscription } from "./events"; /** * A collection of graph properties in a schema. */ export declare class DataTypeCollection extends BaseCollection { private _schema; private _size; private _types; private _events?; private constructor(); /** * Gets the schema that owns the collection. */ get schema(): GraphSchema; /** * Gets the number of properties in the collection. */ get size(): number; /** * Creates a subscription for a set of named events. */ subscribe(events: DataTypeCollectionEvents): EventSubscription; /** * Determines whether the collection contains the specified data type. */ has(type: DataTypeNameLike, packageQualifier?: string): boolean; /** * Determines whether the collection contains the specified data type. */ has(type: DataTypeNameLike | DataType): boolean; /** * Gets the data type with the specified id. */ get(name: DataTypeNameLike, packageQualifier?: string): DataType | undefined; /** * Gets the data type with the specified name. If one does not exist, a new data type is created. */ getOrCreate(name: DataTypeNameLike, validator?: ((value: any) => value is V) | ((value: any) => boolean)): DataType; /** * Gets the data type with the specified name. If one does not exist, a new data type is created. */ getOrCreate(name: DataTypeNameLike, options?: DataTypeOptions): DataType; /** * Gets the data type with the specified name. If one does not exist, a new data type is created. */ getOrCreate(name: DataTypeNameLike, packageQualifier?: string, validator?: ((value: any) => value is V) | ((value: any) => boolean)): DataType; /** * Gets the data type with the specified name. If one does not exist, a new data type is created. */ getOrCreate(name: DataTypeNameLike, packageQualifier?: string, options?: DataTypeOptions): DataType; /** * Gets the data type for the provided class. If one does not exist, a new data type is created. */ getOrCreateClass(ctor: new (...args: any) => V, packageQualifier?: string, options?: DataTypeOptions): DataType; /** * Adds a data type to the collection. */ add(dataType: DataType): this; /** * Removes a data type from the collection. */ delete(dataType: DataType): boolean; /** * Removes a data type from the collection. */ delete(dataType: DataTypeNameLike, packageQualifier?: string): DataType | false; /** * Removes a data type from the collection. */ delete(dataType: DataType | DataTypeNameLike): DataType | boolean; /** * Removes all data types from the collection. */ clear(): void; /** * Gets the data types in the collection. */ values(): IterableIterator; /** * Gets the data types in the collection. */ [Symbol.iterator](): IterableIterator; private _raiseOnAdded; private _raiseOnDeleted; } export interface DataTypeCollectionEvents { /** * An event raised when a data type is added to the collection. */ onAdded?: (type: DataType) => void; /** * An event raised when a data type is removed from the collection. */ onDeleted?: (type: DataType) => void; }