PartialTransformerDefinition

io.scalaland.chimney.dsl.PartialTransformerDefinition
final class PartialTransformerDefinition[From, To, Overrides <: TransformerOverrides, Flags <: TransformerFlags](val runtimeData: RuntimeDataStore) extends WithRuntimeDataStore

Allows customization of io.scalaland.chimney.PartialTransformer derivation.

Type parameters

Flags

type-level encoded flags

From

type of input value

Overrides

type-level encoded config

To

type of output value

Attributes

Since

0.7.0

Graph
Supertypes
trait WithRuntimeDataStore
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

inline def buildTransformer[ImplicitScopeFlags <: TransformerFlags](using tc: TransformerConfiguration[ImplicitScopeFlags]): PartialTransformer[From, To]

Build Partial Transformer using current configuration.

Build Partial Transformer using current configuration.

It runs macro that tries to derive instance of PartialTransformer[From, To]. When transformation can't be derived, it results with compilation error.

Attributes

Returns

io.scalaland.chimney.PartialTransformer type class instance

Since

0.7.0

transparent inline def withConstructor[Ctor](inline f: Ctor)(using Of[Ctor, To]): PartialTransformerDefinition[From, To, _ <: TransformerOverrides, Flags]

Use f instead of the primary constructor to construct the To value.

Use f instead of the primary constructor to construct the To value.

Macro will read the names of Eta-expanded method's/lambda's parameters and try to match them with From getters.

Values for each parameter can be provided the same way as if they were normal constructor's arguments.

Type parameters

Ctor

type of the Eta-expanded method/lambda which should return To

Value parameters

f

method name or lambda which constructs To

Attributes

Returns

io.scalaland.chimney.dsl.PartialTransformerDefinition

See also
Since

0.8.4

transparent inline def withConstructorEither[Ctor](inline f: Ctor)(using Of[Ctor, Either[String, To]]): PartialTransformerDefinition[From, To, _ <: TransformerOverrides, Flags]

Use f instead of the primary constructor to parse into Either[String, To] value.

Use f instead of the primary constructor to parse into Either[String, To] value.

Macro will read the names of Eta-expanded method's/lambda's parameters and try to match them with From getters.

Values for each parameter can be provided the same way as if they were normal constructor's arguments.

Type parameters

Ctor

type of the Eta-expanded method/lambda which should return Either[String, To]

Value parameters

f

method name or lambda which constructs Either[String, To]

Attributes

Returns

io.scalaland.chimney.dsl.PartialTransformerDefinition

See also
Since

1.0.0

transparent inline def withConstructorPartial[Ctor](inline f: Ctor)(using Of[Ctor, Result[To]]): PartialTransformerDefinition[From, To, _ <: TransformerOverrides, Flags]

Use f instead of the primary constructor to parse into partial.Result[To] value.

Use f instead of the primary constructor to parse into partial.Result[To] value.

Macro will read the names of Eta-expanded method's/lambda's parameters and try to match them with From getters.

Values for each parameter can be provided the same way as if they were normal constructor's arguments.

Type parameters

Ctor

type of the Eta-expanded method/lambda which should return partial.Result[To]

Value parameters

f

method name or lambda which constructs partial.Result[To]

Attributes

Returns

io.scalaland.chimney.dsl.PartialTransformerDefinition

See also
Since

0.8.4

transparent inline def withEnumCaseHandled[Subtype](inline f: Subtype => To): PartialTransformerDefinition[From, To, _ <: TransformerOverrides, Flags]

Attributes

Since

1.0.0

transparent inline def withEnumCaseHandledPartial[Subtype](inline f: Subtype => Result[To]): PartialTransformerDefinition[From, To, _ <: TransformerOverrides, Flags]

Attributes

Since

1.0.0

transparent inline def withFieldComputed[T, U](inline selector: To => T, inline f: From => U)(using U <:< T): PartialTransformerDefinition[From, To, _ <: TransformerOverrides, Flags]

Use function f to compute value of field picked using selector.

Use function f to compute value of field picked using selector.

By default if From is missing field picked by selector compilation fails.

Type parameters

T

type of target field

U

type of computed value

Value parameters

f

function used to compute value of the target field

selector

target field in To, defined like _.name

Attributes

Returns

io.scalaland.chimney.dsl.PartialTransformerDefinition

See also
Since

0.7.0

transparent inline def withFieldComputedPartial[T, U](inline selector: To => T, inline f: From => Result[U])(using U <:< T): PartialTransformerDefinition[From, To, _ <: TransformerOverrides, Flags]

Use function f to compute partial result for field picked using selector.

Use function f to compute partial result for field picked using selector.

By default if From is missing field picked by selector compilation fails.

Type parameters

T

type of target field

U

type of computed value

Value parameters

f

function used to compute value of the target field

selector

target field in To, defined like _.name

Attributes

Returns

io.scalaland.chimney.dsl.PartialTransformerDefinition

See also
Since

0.7.0

transparent inline def withFieldConst[T, U](inline selector: To => T, inline value: U)(using U <:< T): PartialTransformerDefinition[From, To, _ <: TransformerOverrides, Flags]

Use provided value for field picked using selector.

Use provided value for field picked using selector.

By default if From is missing field picked by selector, compilation fails.

Type parameters

T

type of target field

U

type of provided value

Value parameters

selector

target field in To, defined like _.name

value

constant value to use for the target field

Attributes

Returns

io.scalaland.chimney.dsl.PartialTransformerDefinition

See also
Since

0.7.0

transparent inline def withFieldConstPartial[T, U](inline selector: To => T, inline value: Result[U])(using U <:< T): PartialTransformerDefinition[From, To, _ <: TransformerOverrides, Flags]

Use provided partial result value for field picked using selector.

Use provided partial result value for field picked using selector.

By default if From is missing field picked by selector, compilation fails.

Type parameters

T

type of target field

U

type of computed value

Value parameters

selector

target field in To, defined like _.name

value

constant value to use for the target field

Attributes

Returns

io.scalaland.chimney.dsl.PartialTransformerDefinition

See also
Since

0.7.0

transparent inline def withFieldRenamed[T, U](inline selectorFrom: From => T, inline selectorTo: To => U): PartialTransformerDefinition[From, To, _ <: TransformerOverrides, Flags]

Use selectorFrom field in From to obtain the value of selectorTo field in To

Use selectorFrom field in From to obtain the value of selectorTo field in To

By default if From is missing field picked by selectorTo compilation fails.

Type parameters

T

type of source field

U

type of target field

Value parameters

selectorFrom

source field in From, defined like _.originalName

selectorTo

target field in To, defined like _.newName

Attributes

Returns

io.scalaland.chimney.dsl.PartialTransformerDefinition

See also
Since

0.7.0

transparent inline def withSealedSubtypeHandled[Subtype](inline f: Subtype => To): PartialTransformerDefinition[From, To, _ <: TransformerOverrides, Flags]

Use f to calculate the unmatched subtype when mapping one sealed/enum into another.

Use f to calculate the unmatched subtype when mapping one sealed/enum into another.

By default if mapping one coproduct in From into another coproduct in To derivation expects that coproducts to have matching names of its components, and for every component in To field's type there is matching component in From type. If some component is missing it fails compilation unless provided replacement with this operation.

For convenience/readability withEnumCaseHandled alias can be used (e.g. for Scala 3 enums or Java enums).

It differs from withFieldComputed(_.matching[Subtype], src => ...), since withSealedSubtypeHandled matches on From subtype, while .matching[Subtype] matches on To value's piece.

Type parameters

Subtype

type of sealed/enum instance

Value parameters

f

function to calculate values of components that cannot be mapped automatically

Attributes

Returns

io.scalaland.chimney.dsl.PartialTransformerDefinition

See also
Since

1.0.0

transparent inline def withSealedSubtypeHandledPartial[Subtype](inline f: Subtype => Result[To]): PartialTransformerDefinition[From, To, _ <: TransformerOverrides, Flags]

Use f to calculate the unmatched subtype's partial.Result when mapping one sealed/enum into another.

Use f to calculate the unmatched subtype's partial.Result when mapping one sealed/enum into another.

By default if mapping one coproduct in From into another coproduct in To derivation expects that coproducts to have matching names of its components, and for every component in To field's type there is matching component in From type. If some component is missing it fails compilation unless provided replacement with this operation.

For convenience/readability withEnumCaseHandledPartial alias can be used (e.g. for Scala 3 enums or Java enums).

It differs from withFieldComputedPartial(_.matching[Subtype], src => ...), since withSealedSubtypeHandled matches on From subtype, while .matching[Subtype] matches on To value's piece.

Type parameters

Subtype

type of sealed/enum instance

Value parameters

f

function to calculate values of components that cannot be mapped automatically

Attributes

Returns

io.scalaland.chimney.dsl.PartialTransformerDefinition

See also
Since

1.0.0

Deprecated methods

transparent inline def withCoproductInstance[Subtype](inline f: Subtype => To): PartialTransformerDefinition[From, To, _ <: TransformerOverrides, Flags]

Attributes

Since

0.1.2

Deprecated
true
transparent inline def withCoproductInstancePartial[Subtype](inline f: Subtype => Result[To]): PartialTransformerDefinition[From, To, _ <: TransformerOverrides, Flags]

Attributes

Since

0.7.0

Deprecated
true

Inherited methods

def disableBeanGetters: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Disable[BeanGetters, Flags]]

Disable Java Beans naming convention (.getName, .isName) on From.

Disable Java Beans naming convention (.getName, .isName) on From.

Attributes

See also
Since

0.6.0

Inherited from:
TransformerFlagsDsl (hidden)
def disableBeanSetters: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Disable[BeanSetters, Flags]]

Disable Java Beans naming convention (.setName(value)) on To.

Disable Java Beans naming convention (.setName(value)) on To.

Attributes

See also
Since

0.6.0

Inherited from:
TransformerFlagsDsl (hidden)
def disableCustomFieldNameComparison: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Disable[FieldNameComparison[_], Flags]]

Disable any custom way of comparing if source fields' names and target fields' names are matching.

Disable any custom way of comparing if source fields' names and target fields' names are matching.

Attributes

See also
Since

1.0.0

Inherited from:
TransformerFlagsDsl (hidden)
def disableCustomSubtypeNameComparison: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Disable[SubtypeNameComparison[_], Flags]]

Disable any custom way of comparing if source subtypes' names and target fields' names are matching.

Disable any custom way of comparing if source subtypes' names and target fields' names are matching.

Attributes

See also
Since

1.0.0

Inherited from:
TransformerFlagsDsl (hidden)
def disableDefaultValues: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Disable[DefaultValues, Flags]]

Fail derivation if From type is missing field even if To has default value for it.

Fail derivation if From type is missing field even if To has default value for it.

Attributes

See also
Since

0.1.9

Inherited from:
TransformerFlagsDsl (hidden)
def disableIgnoreUnmatchedBeanSetters: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Disable[BeanSettersIgnoreUnmatched, Flags]]

Disable not failing compilation on unresolved Java Beans naming convention (.setName(value)) in To.

Disable not failing compilation on unresolved Java Beans naming convention (.setName(value)) in To.

Attributes

See also
Since

0.8.3

Inherited from:
TransformerFlagsDsl (hidden)
def disableImplicitConflictResolution: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Disable[ImplicitConflictResolution[_], Flags]]

Disable any implicit conflict resolution preference that was set previously.

Disable any implicit conflict resolution preference that was set previously.

Attributes

See also
Since

0.7.0

Inherited from:
TransformerFlagsDsl (hidden)
def disableInheritedAccessors: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Disable[InheritedAccessors, Flags]]

Disable inherited accessors lookup that was previously enabled by enableInheritedAccessors

Disable inherited accessors lookup that was previously enabled by enableInheritedAccessors

Attributes

See also
Since

0.8.0

Inherited from:
TransformerFlagsDsl (hidden)
def disableMacrosLogging: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Disable[MacrosLogging, Flags]]

Disable printing the logs from the derivation process.

Disable printing the logs from the derivation process.

Attributes

See also
Since

0.8.0

Inherited from:
TransformerFlagsDsl (hidden)
def disableMethodAccessors: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Disable[MethodAccessors, Flags]]

Disable method accessors lookup that was previously enabled by enableMethodAccessors

Disable method accessors lookup that was previously enabled by enableMethodAccessors

Attributes

See also
Since

0.5.0

Inherited from:
TransformerFlagsDsl (hidden)
def disableNonUnitBeanSetters: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Disable[NonUnitBeanSetters, Flags]]

Enable calling unary non-Unit methods with Java Beans naming convention (.setName(value)) in To.

Enable calling unary non-Unit methods with Java Beans naming convention (.setName(value)) in To.

Attributes

See also
Since

1.0.0

Inherited from:
TransformerFlagsDsl (hidden)
def disableOptionDefaultsToNone: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Disable[OptionDefaultsToNone, Flags]]

Disable None fallback value for optional fields in To.

Disable None fallback value for optional fields in To.

Attributes

See also
Since

0.6.0

Inherited from:
TransformerFlagsDsl (hidden)
def disablePartialUnwrapsOption: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Disable[PartialUnwrapsOption, Flags]]

Disable safe Option unwrapping by PartialTransformer - each Option to non-Option` has to be handled manually.

Disable safe Option unwrapping by PartialTransformer - each Option to non-Option` has to be handled manually.

Attributes

See also
Since

1.0.0

Inherited from:
TransformerFlagsDsl (hidden)
def enableBeanGetters: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Enable[BeanGetters, Flags]]

Enable Java Beans naming convention (.getName, .isName) on From.

Enable Java Beans naming convention (.getName, .isName) on From.

By default only Scala conversions (.name) are allowed.

Attributes

See also
Since

0.2.1

Inherited from:
TransformerFlagsDsl (hidden)
def enableBeanSetters: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Enable[BeanSetters, Flags]]

Enable Java Beans naming convention (.setName(value)) on To.

Enable Java Beans naming convention (.setName(value)) on To.

By default only Scala conversions (.copy(name = value)) are allowed.

Attributes

See also
Since

0.2.1

Inherited from:
TransformerFlagsDsl (hidden)
def enableCustomFieldNameComparison[C <: TransformedNamesComparison & Singleton](namesComparison: C): [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Enable[FieldNameComparison[C], Flags]]

Enable custom way of comparing if source fields' names and target fields' names are matching.

Enable custom way of comparing if source fields' names and target fields' names are matching.

Value parameters

namesComparison

parameter specifying how names should be compared by macro

Attributes

See also
Since

1.0.0

Inherited from:
TransformerFlagsDsl (hidden)
def enableCustomSubtypeNameComparison[C <: TransformedNamesComparison & Singleton](namesComparison: C): [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Enable[SubtypeNameComparison[C], Flags]]

Enable custom way of comparing if source subtypes' names and target fields' names are matching.

Enable custom way of comparing if source subtypes' names and target fields' names are matching.

Value parameters

namesComparison

parameter specifying how names should be compared by macro

Attributes

See also
Since

1.0.0

Inherited from:
TransformerFlagsDsl (hidden)
def enableDefaultValues: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Enable[DefaultValues, Flags]]

Enable fallback to default case class values in To type.

Enable fallback to default case class values in To type.

By default in such case derivation will fail. By enabling this flag, derivation will fallback to default value.

Attributes

See also
Since

0.6.0

Inherited from:
TransformerFlagsDsl (hidden)
def enableIgnoreUnmatchedBeanSetters: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Enable[BeanSettersIgnoreUnmatched, Flags]]

Enable not failing compilation on unresolved Java Beans naming convention (.setName(value)) in To.

Enable not failing compilation on unresolved Java Beans naming convention (.setName(value)) in To.

By default presence of setters (.setName(value)) fails compilation unless setters are enabled and matched with a source field or provided valued.

Attributes

See also
Since

0.8.3

Inherited from:
TransformerFlagsDsl (hidden)
def enableImplicitConflictResolution[P <: ImplicitTransformerPreference](preference: P): [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Enable[ImplicitConflictResolution[P], Flags]]

Enable conflict resolution when both Transformer and PartialTransformer are available in the implicit scope.

Enable conflict resolution when both Transformer and PartialTransformer are available in the implicit scope.

Value parameters

preference

parameter specifying which implicit transformer to pick in case of conflict

Attributes

See also
Since

0.7.0

Inherited from:
TransformerFlagsDsl (hidden)
def enableInheritedAccessors: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Enable[InheritedAccessors, Flags]]

Enable lookup in definitions inherited from supertype.

Enable lookup in definitions inherited from supertype.

By default only values defined directly in the type are considered. With this flag supertype methods would not be filtered out

Attributes

See also
Since

0.8.0

Inherited from:
TransformerFlagsDsl (hidden)
def enableMacrosLogging: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Enable[MacrosLogging, Flags]]

Enable printing the logs from the derivation process.

Enable printing the logs from the derivation process.

Attributes

See also
Since

0.8.0

Inherited from:
TransformerFlagsDsl (hidden)
def enableMethodAccessors: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Enable[MethodAccessors, Flags]]

Enable values to be supplied from method calls. Source method must be public and have no parameter list.

Enable values to be supplied from method calls. Source method must be public and have no parameter list.

By default this is disabled because method calls may perform side effects (e.g. mutations)

Attributes

See also
Since

0.6.0

Inherited from:
TransformerFlagsDsl (hidden)
def enableNonUnitBeanSetters: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Enable[NonUnitBeanSetters, Flags]]

Enable calling unary non-Unit methods with Java Beans naming convention (.setName(value)) in To.

Enable calling unary non-Unit methods with Java Beans naming convention (.setName(value)) in To.

By default only methods returning Unit (setName(value): Unit) could be considered setters.

Attributes

See also
Since

1.0.0

Inherited from:
TransformerFlagsDsl (hidden)
def enableOptionDefaultsToNone: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Enable[OptionDefaultsToNone, Flags]]

Sets target value of optional field to None if field is missing from source type From.

Sets target value of optional field to None if field is missing from source type From.

By default in such case compilation fails.

Attributes

See also
Since

0.2.1

Inherited from:
TransformerFlagsDsl (hidden)
def enablePartialUnwrapsOption: [Flags1 <: TransformerFlags] =>> PartialTransformerDefinition[From, To, Overrides, Flags1][Enable[PartialUnwrapsOption, Flags]]

Enable safe Option unwrapping by PartialTransformer - Option is automatically unwrapped to non-Option values, None is treated as empty value errors.

Enable safe Option unwrapping by PartialTransformer - Option is automatically unwrapped to non-Option values, None is treated as empty value errors.

This is the default behavior.

Attributes

See also
Since

1.0.0

Inherited from:
TransformerFlagsDsl (hidden)

Concrete fields

runtime storage for values and functions that transformer definition is customized with

runtime storage for values and functions that transformer definition is customized with

Attributes