final class TransformerDefinition[From, To, Overrides <: TransformerOverrides, Flags <: TransformerFlags] extends TransformerFlagsDsl[[Flags1]TransformerDefinition[From, To, Overrides, Flags1], Flags] with TransformerDefinitionCommons[[Overrides1]TransformerDefinition[From, To, Overrides1, Flags]] with WithRuntimeDataStore
Allows customization of io.scalaland.chimney.Transformer derivation.
- From
type of input value
- To
type of output value
- Overrides
type-level encoded config
- Flags
type-level encoded flags
- Since
0.4.0
- Alphabetic
- By Inheritance
- TransformerDefinition
- WithRuntimeDataStore
- TransformerDefinitionCommons
- TransformerFlagsDsl
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new TransformerDefinition(runtimeData: RuntimeDataStore)
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- macro def buildTransformer[ImplicitScopeFlags <: TransformerFlags](implicit tc: TransformerConfiguration[ImplicitScopeFlags]): Transformer[From, To]
Build Transformer using current configuration.
Build Transformer using current configuration.
It runs macro that tries to derive instance of
Transformer[From, To]
. When transformation can't be derived, it results with compilation error.- returns
io.scalaland.chimney.Transformer type class instance
- Since
0.4.0
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def disableBeanGetters: TransformerDefinition[From, To, Overrides, Disable[BeanGetters, Flags]]
Disable Java Beans naming convention (
.getName
,.isName
) onFrom
.Disable Java Beans naming convention (
.getName
,.isName
) onFrom
.- Definition Classes
- TransformerFlagsDsl
- Since
0.6.0
- See also
https://chimney.readthedocs.io/supported-transformations/#reading-from-bean-getters for more details
- def disableBeanSetters: TransformerDefinition[From, To, Overrides, Disable[BeanSetters, Flags]]
Disable Java Beans naming convention (
.setName(value)
) onTo
.Disable Java Beans naming convention (
.setName(value)
) onTo
.- Definition Classes
- TransformerFlagsDsl
- Since
0.6.0
- See also
https://chimney.readthedocs.io/supported-transformations/#writing-to-bean-setters for more details
- def disableCustomFieldNameComparison: TransformerDefinition[From, To, Overrides, 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.
- Definition Classes
- TransformerFlagsDsl
- Since
1.0.0
- See also
https://chimney.readthedocs.io/supported-transformations/#customizing-field-name-matching for more details
- def disableCustomSubtypeNameComparison: TransformerDefinition[From, To, Overrides, 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.
- Definition Classes
- TransformerFlagsDsl
- Since
1.0.0
- See also
https://chimney.readthedocs.io/supported-transformations/#customizing-subtype-name-matching for more details
- def disableDefaultValues: TransformerDefinition[From, To, Overrides, Disable[DefaultValues, Flags]]
Fail derivation if
From
type is missing field even ifTo
has default value for it.Fail derivation if
From
type is missing field even ifTo
has default value for it.- Definition Classes
- TransformerFlagsDsl
- Since
0.1.9
- See also
https://chimney.readthedocs.io/supported-transformations/#allowing-fallback-to-the-constructors-default-values for more details
- def disableIgnoreUnmatchedBeanSetters: TransformerDefinition[From, To, Overrides, Disable[BeanSettersIgnoreUnmatched, Flags]]
Disable not failing compilation on unresolved Java Beans naming convention (
.setName(value)
) inTo
.Disable not failing compilation on unresolved Java Beans naming convention (
.setName(value)
) inTo
.- Definition Classes
- TransformerFlagsDsl
- Since
0.8.3
- See also
https://chimney.readthedocs.io/supported-transformations/#ignoring-unmatched-bean-setters for more details
- def disableImplicitConflictResolution: TransformerDefinition[From, To, Overrides, Disable[ImplicitConflictResolution[_], Flags]]
Disable any implicit conflict resolution preference that was set previously.
Disable any implicit conflict resolution preference that was set previously.
- Definition Classes
- TransformerFlagsDsl
- Since
0.7.0
- See also
https://chimney.readthedocs.io/supported-transformations/#resolving-priority-of-implicit-total-vs-partial-transformers for more details
- def disableInheritedAccessors: TransformerDefinition[From, To, Overrides, Disable[InheritedAccessors, Flags]]
Disable inherited accessors lookup that was previously enabled by
enableInheritedAccessors
Disable inherited accessors lookup that was previously enabled by
enableInheritedAccessors
- Definition Classes
- TransformerFlagsDsl
- Since
0.8.0
- See also
https://chimney.readthedocs.io/supported-transformations/#reading-from-inherited-valuesmethods for more details
- def disableMacrosLogging: TransformerDefinition[From, To, Overrides, Disable[MacrosLogging, Flags]]
Disable printing the logs from the derivation process.
Disable printing the logs from the derivation process.
- Definition Classes
- TransformerFlagsDsl
- Since
0.8.0
- See also
https://chimney.readthedocs.io/troubleshooting/#debugging-macros for more details
- def disableMethodAccessors: TransformerDefinition[From, To, Overrides, Disable[MethodAccessors, Flags]]
Disable method accessors lookup that was previously enabled by
enableMethodAccessors
Disable method accessors lookup that was previously enabled by
enableMethodAccessors
- Definition Classes
- TransformerFlagsDsl
- Since
0.5.0
- See also
https://chimney.readthedocs.io/supported-transformations/#reading-from-methods for more details
- def disableNonUnitBeanSetters: TransformerDefinition[From, To, Overrides, Disable[NonUnitBeanSetters, Flags]]
Enable calling unary non-Unit methods with Java Beans naming convention (
.setName(value)
) inTo
.Enable calling unary non-Unit methods with Java Beans naming convention (
.setName(value)
) inTo
.- Definition Classes
- TransformerFlagsDsl
- Since
1.0.0
- See also
https://chimney.readthedocs.io/supported-transformations/#writing-to-non-unit-bean-setters for more details
- def disableOptionDefaultsToNone: TransformerDefinition[From, To, Overrides, Disable[OptionDefaultsToNone, Flags]]
Disable
None
fallback value for optional fields inTo
.Disable
None
fallback value for optional fields inTo
.- Definition Classes
- TransformerFlagsDsl
- Since
0.6.0
- See also
https://chimney.readthedocs.io/supported-transformations/#allowing-fallback-to-none-as-the-constructors-argument for more details
- def disablePartialUnwrapsOption: TransformerDefinition[From, To, Overrides, Disable[PartialUnwrapsOption, Flags]]
Disable safe
Option
unwrapping byPartialTransformer
- eachOption
to non-Optionhas to be handled manually.
Disable safe
Option
unwrapping byPartialTransformer
- eachOption
to non-Optionhas to be handled manually.
- Definition Classes
- TransformerFlagsDsl
- Since
1.0.0
- See also
https://chimney.readthedocs.io/supported-transformations/#controlling-automatic-option-unwrapping for more details
- def enableBeanGetters: TransformerDefinition[From, To, Overrides, Enable[BeanGetters, Flags]]
Enable Java Beans naming convention (
.getName
,.isName
) onFrom
.Enable Java Beans naming convention (
.getName
,.isName
) onFrom
.By default only Scala conversions (
.name
) are allowed.- Definition Classes
- TransformerFlagsDsl
- Since
0.2.1
- See also
https://chimney.readthedocs.io/supported-transformations/#reading-from-bean-getters for more details
- def enableBeanSetters: TransformerDefinition[From, To, Overrides, Enable[BeanSetters, Flags]]
Enable Java Beans naming convention (
.setName(value)
) onTo
.Enable Java Beans naming convention (
.setName(value)
) onTo
.By default only Scala conversions (
.copy(name = value)
) are allowed.- Definition Classes
- TransformerFlagsDsl
- Since
0.2.1
- See also
https://chimney.readthedocs.io/supported-transformations/#writing-to-bean-setters for more details
- def enableCustomFieldNameComparison[C <: TransformedNamesComparison with Singleton](namesComparison: C): TransformerDefinition[From, To, Overrides, 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.
- namesComparison
parameter specifying how names should be compared by macro
- Definition Classes
- TransformerFlagsDsl
- Since
1.0.0
- See also
https://chimney.readthedocs.io/supported-transformations/#customizing-field-name-matching for more details
- def enableCustomSubtypeNameComparison[C <: TransformedNamesComparison with Singleton](namesComparison: C): TransformerDefinition[From, To, Overrides, 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.
- namesComparison
parameter specifying how names should be compared by macro
- Definition Classes
- TransformerFlagsDsl
- Since
1.0.0
- See also
https://chimney.readthedocs.io/supported-transformations/#customizing-subtype-name-matching for more details
- def enableDefaultValues: TransformerDefinition[From, To, Overrides, 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.
- Definition Classes
- TransformerFlagsDsl
- Since
0.6.0
- See also
https://chimney.readthedocs.io/supported-transformations/#allowing-fallback-to-the-constructors-default-values for more details
- def enableIgnoreUnmatchedBeanSetters: TransformerDefinition[From, To, Overrides, Enable[BeanSettersIgnoreUnmatched, Flags]]
Enable not failing compilation on unresolved Java Beans naming convention (
.setName(value)
) inTo
.Enable not failing compilation on unresolved Java Beans naming convention (
.setName(value)
) inTo
.By default presence of setters (
.setName(value)
) fails compilation unless setters are enabled and matched with a source field or provided valued.- Definition Classes
- TransformerFlagsDsl
- Since
0.8.3
- See also
https://chimney.readthedocs.io/supported-transformations/#ignoring-unmatched-bean-setters for more details
- def enableImplicitConflictResolution[P <: ImplicitTransformerPreference](preference: P): TransformerDefinition[From, To, Overrides, Enable[ImplicitConflictResolution[P], Flags]]
Enable conflict resolution when both
Transformer
andPartialTransformer
are available in the implicit scope.Enable conflict resolution when both
Transformer
andPartialTransformer
are available in the implicit scope.- preference
parameter specifying which implicit transformer to pick in case of conflict
- Definition Classes
- TransformerFlagsDsl
- Since
0.7.0
- See also
https://chimney.readthedocs.io/supported-transformations/#resolving-priority-of-implicit-total-vs-partial-transformers for more details
- def enableInheritedAccessors: TransformerDefinition[From, To, Overrides, 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
- Definition Classes
- TransformerFlagsDsl
- Since
0.8.0
- See also
https://chimney.readthedocs.io/supported-transformations/#reading-from-inherited-valuesmethods for more details
- def enableMacrosLogging: TransformerDefinition[From, To, Overrides, Enable[MacrosLogging, Flags]]
Enable printing the logs from the derivation process.
Enable printing the logs from the derivation process.
- Definition Classes
- TransformerFlagsDsl
- Since
0.8.0
- See also
https://chimney.readthedocs.io/troubleshooting/#debugging-macros for more details
- def enableMethodAccessors: TransformerDefinition[From, To, Overrides, Enable[MethodAccessors, Flags]]
Enable values to be supplied from method calls.
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)
- Definition Classes
- TransformerFlagsDsl
- Since
0.6.0
- See also
https://chimney.readthedocs.io/supported-transformations/#reading-from-methods for more details
- def enableNonUnitBeanSetters: TransformerDefinition[From, To, Overrides, Enable[NonUnitBeanSetters, Flags]]
Enable calling unary non-Unit methods with Java Beans naming convention (
.setName(value)
) inTo
.Enable calling unary non-Unit methods with Java Beans naming convention (
.setName(value)
) inTo
.By default only methods returning
Unit
(setName(value): Unit
) could be considered setters.- Definition Classes
- TransformerFlagsDsl
- Since
1.0.0
- See also
https://chimney.readthedocs.io/supported-transformations/#writing-to-non-unit-bean-setters for more details
- def enableOptionDefaultsToNone: TransformerDefinition[From, To, Overrides, 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.
- Definition Classes
- TransformerFlagsDsl
- Since
0.2.1
- See also
https://chimney.readthedocs.io/supported-transformations/#allowing-fallback-to-none-as-the-constructors-argument for more details
- def enablePartialUnwrapsOption: TransformerDefinition[From, To, Overrides, 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.
- Definition Classes
- TransformerFlagsDsl
- Since
1.0.0
- See also
https://chimney.readthedocs.io/supported-transformations/#controlling-automatic-option-unwrapping for more details
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def partial: PartialTransformerDefinition[From, To, Overrides, Flags]
Lifts current transformer definition as
PartialTransformer
definition.Lifts current transformer definition as
PartialTransformer
definition.It keeps all the configuration, provided missing values, renames, coproduct instances etc.
- val runtimeData: RuntimeDataStore
runtime storage for values and functions that transformer definition is customized with
runtime storage for values and functions that transformer definition is customized with
- Definition Classes
- TransformerDefinition → TransformerDefinitionCommons
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- macro def withConstructor[Ctor](f: Ctor)(implicit ev: Of[Ctor, To]): TransformerDefinition[From, To, _ <: TransformerOverrides, Flags]
Use
f
instead of the primary constructor to construct theTo
value.Use
f
instead of the primary constructor to construct theTo
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.
- Ctor
type of the Eta-expanded method/lambda which should return
To
- f
method name or lambda which constructs
To
- returns
- Since
0.8.4
- See also
https://chimney.readthedocs.io/supported-transformations/#types-with-manually-provided-constructors for more details
- macro def withEnumCaseHandled[Subtype](f: (Subtype) => To): TransformerDefinition[From, To, _ <: TransformerOverrides, Flags]
Alias to withSealedSubtypeHandled.
Alias to withSealedSubtypeHandled.
- Since
1.0.0
- macro def withFieldComputed[T, U](selector: (To) => T, f: (From) => U)(implicit ev: <:<[U, T]): TransformerDefinition[From, To, _ <: TransformerOverrides, Flags]
Use function
f
to compute value of field picked usingselector
.Use function
f
to compute value of field picked usingselector
.By default if
From
is missing field picked byselector
compilation fails.- T
type of target field
- U
type of computed value
- selector
target field in
To
, defined like_.name
- f
function used to compute value of the target field
- returns
- Since
0.4.0
- See also
https://chimney.readthedocs.io/supported-transformations/#wiring-the-constructors-parameter-to-computed-value for more details
- macro def withFieldConst[T, U](selector: (To) => T, value: U)(implicit ev: <:<[U, T]): TransformerDefinition[From, To, _ <: TransformerOverrides, Flags]
Use provided value
value
for field picked usingselector
.Use provided value
value
for field picked usingselector
.By default if
From
is missing field picked byselector
, compilation fails.- T
type of target field
- U
type of provided value
- selector
target field in
To
, defined like_.name
- value
constant value to use for the target field
- returns
- Since
0.4.0
- See also
https://chimney.readthedocs.io/supported-transformations/#wiring-the-constructors-parameter-to-a-provided-value for more details
- macro def withFieldRenamed[T, U](selectorFrom: (From) => T, selectorTo: (To) => U): TransformerDefinition[From, To, _ <: TransformerOverrides, Flags]
Use
selectorFrom
field inFrom
to obtain the value ofselectorTo
field inTo
Use
selectorFrom
field inFrom
to obtain the value ofselectorTo
field inTo
By default if
From
is missing field picked byselectorTo
compilation fails.- T
type of source field
- U
type of target field
- selectorFrom
source field in
From
, defined like_.originalName
- selectorTo
target field in
To
, defined like_.newName
- returns
- Since
0.4.0
- See also
https://chimney.readthedocs.io/supported-transformations/#wiring-the-constructors-parameter-to-its-source-field for more details
- macro def withSealedSubtypeHandled[Subtype](f: (Subtype) => To): TransformerDefinition[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 inTo
derivation expects that coproducts to have matching names of its components, and for every component inTo
field's type there is matching component inFrom
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 => ...)
, sincewithSealedSubtypeHandled
matches onFrom
subtype, while.matching[Subtype]
matches onTo
value's piece.- Subtype
type of sealed/enum instance
- f
function to calculate values of components that cannot be mapped automatically
- returns
- Since
1.0.0
- See also
https://chimney.readthedocs.io/supported-transformations/#handling-a-specific-sealed-subtype-with-a-computed-value for more details
Deprecated Value Members
- macro def withCoproductInstance[Subtype](f: (Subtype) => To): TransformerDefinition[From, To, _ <: TransformerOverrides, Flags]
Renamed to withSealedSubtypeHandled.
Renamed to withSealedSubtypeHandled.
- Annotations
- @deprecated
- Deprecated
(Since version 1.0.0) Use .withSealedSubtypeHandled or .withEnumCaseHandled for more clarity
- Since
0.4.0