Kotlin: 2.1.20
KSP: 2.1.20-1.0.32
KOMM: 0.22.8
I'm looking for some advice on how to properly map enums, as that does not seem to be something the library currently does natively. I've tried setting up a converter for it, but end up with the error included at the bottom when compiling. Note, my use case is when mapping "to" with annotations on the Source object, but even if I rearrange the annotations to be on the Destination object, I get the same error.
Example:
import com.ucasoft.komm.abstractions.KOMMConverter
import com.ucasoft.komm.annotations.KOMMMap
import com.ucasoft.komm.annotations.MapConvert
@KOMMMap(to = [ThirdPartyFoo::class])
data class FooDto(
val name: String,
val amt: Int,
@MapConvert<FooDto, BarEnumConverter>(BarEnumConverter::class)
val barEnum: DtoBarEnum
) {
enum class DtoBarEnum {
BEEP,
BOOP
}
}
data class ThirdPartyFoo(
val name: String,
val amt: Int,
val barEnum: BarEnum
) {
enum class BarEnum {
BEEP,
BOOP
}
}
class BarEnumConverter(source: FooDto) : KOMMConverter<FooDto, FooDto.DtoBarEnum, ThirdPartyFoo.BarEnum>(source) {
override fun convert(sourceMember: FooDto.DtoBarEnum): ThirdPartyFoo.BarEnum {
return ThirdPartyFoo.BarEnum.valueOf(sourceMember.name)
}
}
Error:
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':api:kspKotlin'.
Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.google.devtools.ksp.gradle.KspAAWorkerAction
Caused by: java.util.NoSuchElementException: List is empty.
at kotlin.collections.CollectionsKt___CollectionsKt.first(_Collections.kt:221)
at com.ucasoft.komm.processor.KOMMAnnotationFinder.associateWithFor(KOMMAnnotationFinder.kt:86)
at com.ucasoft.komm.processor.KOMMAnnotationFinder.getSuitedNamedAnnotationsForClass(KOMMAnnotationFinder.kt:77)
at com.ucasoft.komm.processor.KOMMAnnotationFinder.getSuitedNamedAnnotations(KOMMAnnotationFinder.kt:70)
at com.ucasoft.komm.processor.KOMMPropertyMapper.getMapNames(KOMMPropertyMapper.kt:59)
at com.ucasoft.komm.processor.KOMMPropertyMapper.getSourceProperties$lambda$6(KOMMPropertyMapper.kt:104)
at kotlin.sequences.FlatteningSequence$iterator$1.ensureItemIterator(Sequences.kt:330)
at kotlin.sequences.FlatteningSequence$iterator$1.hasNext(Sequences.kt:318)
at com.ucasoft.komm.processor.KOMMPropertyMapper.getSourceProperties(KOMMPropertyMapper.kt:194)
at com.ucasoft.komm.processor.KOMMPropertyMapper.<init>(KOMMPropertyMapper.kt:25)
at com.ucasoft.komm.processor.KOMMVisitor.buildStatement(KOMMVisitor.kt:104)
at com.ucasoft.komm.processor.KOMMVisitor.buildFunction(KOMMVisitor.kt:80)
at com.ucasoft.komm.processor.KOMMVisitor.visitClassDeclaration(KOMMVisitor.kt:61)
at com.ucasoft.komm.processor.KOMMVisitor.visitClassDeclaration(KOMMVisitor.kt:19)
at com.google.devtools.ksp.impl.symbol.kotlin.KSClassDeclarationImpl.accept(KSClassDeclarationImpl.kt:179)
at com.ucasoft.komm.processor.KOMMSymbolProcessor.process(KOMMSymbolProcessor.kt:38)
Kotlin: 2.1.20
KSP: 2.1.20-1.0.32
KOMM: 0.22.8
I'm looking for some advice on how to properly map enums, as that does not seem to be something the library currently does natively. I've tried setting up a converter for it, but end up with the error included at the bottom when compiling. Note, my use case is when mapping "to" with annotations on the Source object, but even if I rearrange the annotations to be on the Destination object, I get the same error.
Example:
Error: