@hashgraph/solo
    Preparing search index...

    The ObjectMapper interface defines the methods for converting between plain javascript objects and class instances.

    This is an abstraction that allows the data layer to be decoupled from the underlying object mapper implementation.

    interface ObjectMapper {
        applyPropertyValue(
            object: object,
            key: string,
            value: object | Primitive | PrimitiveArray | object[],
        ): void;
        fromArray<T>(cls: ClassConstructor<T>, array: object[]): T[];
        fromObject<T>(cls: ClassConstructor<T>, object: object): T;
        toArray<T>(data: T[]): object[];
        toFlatKeyMap(data: object): Map<string, string>;
        toObject<T>(data: T): object;
    }

    Implemented by

    Index

    Methods

    • Sets the value of a property on an object hierarchy as specified by the key.

      Parameters

      • object: object

        The object on which to set the property value.

      • key: string

        The key specifying the property to set.

      • value: object | Primitive | PrimitiveArray | object[]

        The value to set.

      Returns void

    • Converts an array of plain javascript objects into an array of instances of the specified class.

      Type Parameters

      • T

      Parameters

      • cls: ClassConstructor<T>

        The desired class of the resulting object instances.

      • array: object[]

        The array of plain javascript objects to be converted.

      Returns T[]

      ObjectMappingError if the mapping or a type conversion fails.

    • Converts a plain javascript object into an instance of the specified class.

      Type Parameters

      • T

      Parameters

      • cls: ClassConstructor<T>

        The desired class of the resulting object instance.

      • object: object

        The plain javascript object to be converted.

      Returns T

      ObjectMappingError if the mapping or a type conversion fails.

    • Converts an array of instances of a class into an array of plain javascript objects.

      Type Parameters

      • T

      Parameters

      • data: T[]

        The array of object instances to be converted.

      Returns object[]

      ObjectMappingError if the mapping or a type conversion fails.

    • Converts a plain javascript object into a flat Map of key-value pairs.

      Parameters

      • data: object

        The plain javascript object to be converted.

      Returns Map<string, string>

      A Map of key-value pairs.

    • Converts an instance of a class into a plain javascript object.

      Type Parameters

      • T

      Parameters

      • data: T

        The object instance to be converted.

      Returns object

      ObjectMappingError if the mapping or a type conversion fails.