import { Document } from '../../../core/models/Document'; import { Node } from '../../../core/models/Node'; /** * Contains basic functionality for manipulation with references within a document. *

* Each schema may work with references in a different way, so an implementation * of this interface is provided for each {@link io.apicurio.datamodels.core.models.Document} type. * * @author Jakub Senko * @class */ export interface IReferenceManipulationStrategy { /** * Add the node to the document (wrapped) as a component/definition. *

* Given a node, if it can be represented as a {@link io.apicurio.datamodels.core.models.common.IDefinition}, * it's wrapped into one and attached to the appropriate place in the document. *

* This new definition node is returned (the original itself is not attached), * together with a canonical reference to the new definition. *

* The reference is generated from the provided name. If a definition with the provided name * already exists, throw an {@link java.lang.IllegalArgumentException}. * * @param {Document} model Target model to manipulate * @param {string} name Suggested definition name * @param {Node} component Node to be attached as a definition * @return {IReferenceManipulationStrategy.ReferenceAndNode} new definition node with the new reference to it * @throws java.lang.IllegalArgumentException if there is a naming conflict. // TODO some better way? */ attachAsDefinition(model: Document, name: string, component: Node): IReferenceManipulationStrategy.ReferenceAndNode; /** * Get a collection of local components/definitions, mapped by their local reference string. * * @param {Document} model * @return * @return {*} */ getExistingLocalComponents(model: Document): any; } export declare namespace IReferenceManipulationStrategy { /** * @param {string} ref nullable * @param {Node} node nullable * @class */ class ReferenceAndNode { ref: string; node: Node; constructor(ref: string, node: Node); getRef(): string; getNode(): Node; /** * * @param {*} o * @return {boolean} */ equals(o: any): boolean; /** * * @return {number} */ hashCode(): number; } }