/*! * 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 { GraphMetadata } from "./graphMetadata"; import { GraphCategory } from "./graphCategory"; import { BaseCollection } from "./baseCollection"; import { EventSubscription } from "./events"; import { GraphCategoryIdLike } from "./graphCategoryIdLike"; /** * A collection of graph categories in a schema. */ export declare class GraphCategoryCollection extends BaseCollection { private _schema; private _categories; private _events?; /** @private */ private constructor(); /** * Gets the schema that owns the collection. */ get schema(): GraphSchema; /** * Gets the number of categories in the collection. */ get size(): number; /** * Creates a subscription for a set of named events. */ subscribe(events: GraphCategoryCollectionEvents): EventSubscription; /** * Determines whether the collection contains the specified category. */ has(category: GraphCategory | GraphCategoryIdLike): boolean; /** * Gets the category with the provided id. */ get(id: GraphCategoryIdLike): GraphCategory | undefined; /** * Gets the category with the provided id. If one does not exist, a new category is created. */ getOrCreate(id: GraphCategoryIdLike, metadataFactory?: () => GraphMetadata): GraphCategory; /** * Adds a category to the collection. */ add(category: GraphCategory): this; /** * Removes a category from the collection. */ delete(category: GraphCategory): boolean; /** * Removes a category from the collection. */ delete(category: GraphCategoryIdLike): GraphCategory | false; /** * Removes a category from the collection. */ delete(category: GraphCategory | GraphCategoryIdLike): GraphCategory | boolean; /** * Removes all categories from the collection. */ clear(): void; /** * Creates an iterator for the values in the collection. */ values(categoryIds?: Iterable): IterableIterator; /** * Creates an iterator for the values in the collection. */ [Symbol.iterator](): IterableIterator; /** * Creates an iterator for the categories in the collection based on the provided base category. */ basedOn(base: GraphCategory | GraphCategoryIdLike): IterableIterator; private _raiseOnAdded; private _raiseOnDeleted; } export interface GraphCategoryCollectionEvents { /** * An event raised when a category is added to the collection. */ onAdded?: (category: GraphCategory) => void; /** * An event raised when a category is removed from the collection. */ onDeleted?: (category: GraphCategory) => void; }