⌘K

NativeTypeProvider

A provider for handling type converters for various data types. NativeTypeProvider maps specific types to their respective converters, allowing easy conversion between objects and their string representations.


NativeTypeProvider

A class that manages type converters for various data types.

class NativeTypeProvider

Properties

  • types: A map that holds type converters, mapping a type to its corresponding INativeType implementation.

Methods

provideTypeConverter

Registers a type converter for a given type.

fun <T : Any> provideTypeConverter(type: KClass<T>, converter: INativeType<T>)
Parameters
  • T: The type for which the converter is being provided.
  • type: The KClass of the type.
  • converter: The implementation of INativeType to handle conversion for the type.

getTypeConverter

Retrieves the type converter for a given type.

fun <T : Any> getTypeConverter(type: KClass<T>): INativeType<T>
Parameters
  • T: The type for which the converter is being retrieved.
  • type: The KClass of the type.
Returns

The INativeType implementation for the requested type.

Throws
  • NotFoundException: If no converter has been registered for the requested type.

INativeType

Defines the contract for converting a type to and from its string representation.

interface INativeType<T>

Methods

toString

Converts an object of type T to its string representation.

fun toString(input: T?): String
Parameters
  • input: The object to be converted.
Returns

The string representation of the input object.

fromString

Converts a string back to an object of type T.

fun fromString(input: String?): T
Parameters
  • input: The string to be converted.
Returns

The object representation of the string.