@KonvertFrom
The annotation @KonvertFrom can only be applied to classes having a companion objects, or to the companion object itself. It will generate an extension function to the companion object to create an instance of the class from the defined source class.
| Annotation on companion | Annotation on class |
|---|---|
| |
Both generate | |
Parameters
constructor
If your target class has multiple constructors, Konvert tries to automatically determine one constructor (TODO). If you want to enforce a specific constructor, you can use this parameter to define the constructor parameter types here.
priority
So that Konvert can choose a TypeConverter if multiple match, you can define a custom priority to align with your setup (TODO). The default priority for this annotation is 4000.
mappings
Define a mapping for each property, which can not be automatically converted. See the @Mapping annotation for details on how to do so.
mapFunctionName
This parameter can be used to change the default name of the extension function (which is from${value.simpleName}, e.g. fromPerson) to whatever you specify. Some typical use-cases for changing the default: the name gets too long or is already taken.
options
You can define custom options for this annotation processing. See here for available options.