/*! * 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 { DataTypeNameLike } from "./dataTypeNameLike"; import type { GraphSchema } from "./graphSchema"; import type { GraphMetadata } from "./graphMetadata"; import type { GraphPropertyIdLike } from "./graphPropertyIdLike"; import type { TypeOfDataTypeName } from "./typeOfDataTypeName"; import { BaseCollection } from "./baseCollection"; import { DataType } from "./dataType"; import { EventSubscription } from "./events"; import { GraphProperty } from "./graphProperty"; /** * A collection of graph properties in a schema. */ export declare class GraphPropertyCollection extends BaseCollection { private _schema; private _properties; 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: GraphPropertyCollectionEvents): EventSubscription; /** * Determines whether the collection contains the specified property. */ has(property: GraphProperty | GraphPropertyIdLike): boolean; /** * Gets the property with the specified id. */ get(id: GraphPropertyIdLike): GraphProperty | undefined; /** * Gets the property with the specified id. If one does not exist, a new property is created. */ getOrCreate(id: GraphPropertyIdLike, metadataFactory?: () => GraphMetadata): GraphProperty; /** * Gets the property with the specified id. If one does not exist, a new property is created. */ getOrCreate(id: GraphPropertyIdLike, dataType?: DataType | readonly DataType[], metadataFactory?: () => GraphMetadata): GraphProperty; /** * Gets the property with the specified id. If one does not exist, a new property is created. */ getOrCreate = TypeOfDataTypeName>(id: GraphPropertyIdLike, dataType: D, packageQualifier: Q, metadataFactory?: () => GraphMetadata): GraphProperty; /** * Gets the property with the specified id. If one does not exist, a new property is created. */ getOrCreate = TypeOfDataTypeName>(id: GraphPropertyIdLike, dataType: D, metadataFactory?: () => GraphMetadata): GraphProperty; /** * Adds a property to the collection. */ add(property: GraphProperty): this; /** * Removes a property from the collection. */ delete(property: GraphProperty): boolean; /** * Removes a property from the collection. */ delete(property: GraphPropertyIdLike): GraphProperty | false; /** * Removes a property from the collection. */ delete(property: GraphProperty | GraphPropertyIdLike): GraphProperty | boolean; /** * Removes all properties from the collection. */ clear(): void; /** * Gets the property keys in the collection. */ keys(): IterableIterator; /** * Gets the properties in the collection. */ values(propertyIds?: Iterable): IterableIterator; /** * Gets the property entries in the collection. */ entries(): IterableIterator<[GraphPropertyIdLike, GraphProperty]>; /** * Gets the properties in the collection. */ [Symbol.iterator](): IterableIterator; private _raiseOnAdded; private _raiseOnDeleted; } export interface GraphPropertyCollectionEvents { /** * An event raised when a property is added to the collection. */ onAdded?: (category: GraphProperty) => void; /** * An event raised when a property is removed from the collection. */ onDeleted?: (category: GraphProperty) => void; }