/*! * Copyright (c) 2019 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 * * SPDX-License-Identifier: EPL-2.0 */ /** * Model to represent an Entity in Ditto. */ export declare abstract class EntityModel { /** * Turns an object into an array of the type A. It contains one Entity for every key of the original object * * @typeParam A - The type of array to return * @param o - The object to parse. * @param parser - A method to parse instances of the desired Entity. * @returns The array of Entities. */ static objectToArray(o: Object, parser: (obj: Object, key: string) => T): T[]; /** * Builds an object representation out of the provided content. * * @param content - The content of the object representation. * @returns The object containing all elements of the content that aren't undefined. */ protected static buildObject(content: Map): object; toJson(): string; equals(toCompare: EntityModel): boolean; /** * Turns the Entity into an object. * * @returns The object representation of the Entity. */ abstract toObject(): Object | undefined; } /** * Entity with an 'id' field */ export declare abstract class EntityWithId extends EntityModel { abstract id: string; equals(toCompare: EntityWithId): boolean; } /** * Abstract entity model class that consists of entities of the same type but with unknown property keys. */ export declare abstract class IndexedEntityModel implements Record { [key: string]: EntryType; static toJson(entity: IndexedEntityModel): string; static equals(a: IndexedEntityModel, b: IndexedEntityModel): boolean; /** * Map the object to an indexed object with types. Iterates all keys and maps all values with {@code mapValue}. * * @param objectToMap - the object to map. * @param mapValue - how to get the value from an objects value. * @param mapKey - how to get the key from an objects key. */ static fromPlainObject(objectToMap: Object | undefined, mapValue: (value: any, key: string) => T, mapKey?: (key: string, value: any) => string): IndexedEntityModel; /** * Removes all type information from the indexed type. * @param objectToMap - the object to map. * @param removeType - function that is called to remove the type of the objects values. */ static toPlainObject(objectToMap: IndexedEntityModel, removeType: (typedObject: T) => any): any; /** * Turns the Entity into an object. * * @returns The object representation of the Entity. */ static toObject(entityModel: IndexedEntityModel | undefined): Object | undefined; } //# sourceMappingURL=model.d.ts.map