Connector

__init__()

Initializes the BaseConnector object.

register(domain_type, solution_type, ...)

Registers a domain type, solution type, and built-in type.

get_type(definition)

Retrieves the solution type based on the input definition.

get_definition(solution_type)

Retrieves the domain type based on the input solution type.

get_builtin(solution_type)

Retrieves the built-in type based on the input solution type.

class BaseConnector

Bases: object

A connector class that maps domain types to solution types and provides type conversion functions.

Parameters:
  • _domain_to_solution (Dict[BaseClass, BaseTypeClass]) – A dictionary mapping domain types to solution types.

  • _solution_to_domain (Dict[BaseTypeClass, BaseClass]) – A dictionary mapping solution types to domain types.

  • _solution_to_builtin (Dict[BaseTypeClass, Any]) – A dictionary mapping solution types to built-in types.

  • _builtin_to_solution (Dict[Any, BaseTypeClass]) – A dictionary mapping built-in types to solution types.

Initializes the BaseConnector object.

Returns:

None

register(domain_type: type[BaseClass], solution_type: type[BaseTypeClass | Solution] | Tuple[type[BaseTypeClass | Solution], str], builtin_type: type[int | float | str | list | dict])

Registers a domain type, solution type, and built-in type.

Parameters:
  • domain_type (type[BaseClass]) – The domain type to register.

  • solution_type (type[BaseTypeClass | types.Solution] or Tuple[type[BaseTypeClass | types.Solution], str]) – The solution type to register.

  • builtin_type (type[int | float | str | list | dict]) – The built-in type to register.

Returns:

None

get_type(definition: Base | int | float | str | list | dict | type[Base | int | float | str | list | dict]) type[BaseTypeClass]

Retrieves the solution type based on the input definition.

Parameters:

definition (definitions.Base or int or float or str or list or dict or type[definitions.Base or int or float or str or list or dict]) – The definition object or type for which to retrieve the solution type.

Returns:

The corresponding solution type.

Return type:

type[BaseTypeClass]

Raises:

ValueError – If the definition is not registered in the connector.

get_definition(solution_type: BaseType | Solution | type[BaseType | Solution] | Tuple[type[BaseType], str]) type[BaseClass]

Retrieves the domain type based on the input solution type.

Parameters:

solution_type (types.BaseType | types.Solution | type[types.BaseType | types.Solution] | Tuple[type[types.BaseType], str]) – The solution type or type object for which to retrieve the domain type.

Returns:

The corresponding domain type.

Return type:

type[BaseClass]

Raises:

ValueError – If the solution type is not registered in the connector.

get_builtin(solution_type: BaseType) type[int | float | str | list | dict]

Retrieves the built-in type based on the input solution type.

Parameters:

solution_type (types.BaseType) – The solution type for which to retrieve the built-in type.

Returns:

The corresponding built-in type.

Return type:

type[int | float | str | list | dict]

Raises:

ValueError – If the solution type is not registered in the connector.