UNPKG

@eclipse-scout/core

Version:
60 lines 3.67 kB
import { BaseDoEntity, Constructor } from '../index'; /** * Holds all data object class mappings. * * Data object classes having an @typeName decorator do register themselves automatically into this registry. * The code to do that is automatically created and injected at compile time. * See DataObjectTransformer#_createDoInventoryAddStatement. * Therefore, the API of this class must match the code generated by this transformer. * If this class name, the method name 'get' (static accessor) or 'add' (to register a data object) are changed, the transformer must be adapted as well! */ export declare class DataObjectInventory { protected static _INSTANCE: DataObjectInventory; protected _constructorByTypeName: Map<string, Constructor<BaseDoEntity>>; protected _typeNameByObjectType: Map<string, string>; protected _objectTypeByTypeName: Map<string, string>; protected constructor(); /** * Adds a new dataobject to the registry. * @param doClass The dataobject class to register. * @param typeName Optional typeName (`_type` attribute) of this dataobject. E.g. `myNamespace.MyEntity`. * If omitted, it will be detected from the given class by creating a new instance and reading the `_type` attribute. * So this attribute must be set either by a `@typeName()` decorator on the class or as part of its constructor. * @param objectType Optional object type of the dataobject. E.g. `myNamespace.MyEntityDo`. * If omitted, it will be read from the `ObjectFactory`. So the constructor must have been registered to the `ObjectFactory` already. * @returns true if the class could be completely registered. false otherwise (e.g. if the typeName or objectType is unknown). */ add(doClass: Constructor<BaseDoEntity>, typeName?: string, objectType?: string): boolean; /** * Removes the dataobject given. * @param item The dataobject class or the typeName (_type) of the dataobject to remove. */ remove(item: Constructor<BaseDoEntity> | string): void; protected _removeByClass(doClass: Constructor<BaseDoEntity>): void; protected _removeByTypeName(typeName: string): void; protected _readTypeName(DoClass: Constructor<BaseDoEntity>): string; /** * @returns All dataobject classes known to the registry. */ getKnownDataObjectClasses(): IterableIterator<Constructor<BaseDoEntity>>; /** * @param typeNameOrObjectType The typeName (_type like 'scout.Topic') or objectType (like 'scout.TopicDo') for which the dataobject class should be returned. * @returns the dataobject class for given typeName (_type) or objectType. */ toConstructor(typeNameOrObjectType: string): Constructor<BaseDoEntity>; /** * @param objectType The objectType for which the typeName (_type) should be returned. E.g. 'scout.CodeDo' or 'myapp.MySpecialDo'. * @returns the dataobject typeName (_type) for given objectType. E.g. returns 'scout.Topic' for 'scout.TopicDo'. Or 'myApp.MySpecial' for 'myApp.MySpecialDo'. This is the inverse operation of {@link toObjectType}. */ toTypeName(objectType: string): string; /** * @param typeName The typeName (_type) for which the objectType should be returned. * @returns the dataobject objectType for given typeName (_type). E.g. returns 'TopicDo' for 'scout.Topic'. Or 'myApp.MySpecialDo' for 'myApp.MySpecial'. This is the inverse operation of {@link toTypeName}. */ toObjectType(typeName: string): string; /** * @returns the DataObjectInventory instance. */ static get(): DataObjectInventory; } //# sourceMappingURL=DataObjectInventory.d.ts.map