Skip to content

Commit

Permalink
feat: throw exception if transformer was not found
Browse files Browse the repository at this point in the history
  • Loading branch information
Idane committed May 4, 2022
1 parent 58d725c commit a0120f8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/dev/krud/shapeshift/ShapeShift.kt
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,17 @@ class ShapeShift(
fromPair: ObjectFieldTrio,
toPair: ObjectFieldTrio
): TransformerRegistration<*, *> {
val transformationPair = Pair<Any?, Any?>(fromPair.type, toPair.type)
val transformationPair = fromPair to toPair
log.trace("Attempting to find transformer for transformation pair [ $transformationPair ]")
var transformerRegistration: TransformerRegistration<*, *> = TransformerRegistration.EMPTY
log.trace("Checking transformerRef field")
if (annotation.transformerRef.isNotBlank()) {
log.trace("transformerRef is not empty with value [ " + annotation.transformerRef + " ]")
transformerRegistration = getTransformerByName(annotation.transformerRef)
if (transformerRegistration != TransformerRegistration.EMPTY) {
log.trace("Found transformer by ref of type [ " + transformerRegistration.transformer.javaClass.name + " ]")
log.trace("Found transformer by ref [ ${annotation.transformerRef} ] of type [ " + transformerRegistration.transformer.javaClass.name + " ]")
} else {
error("Could not find transformer by ref [ ${annotation.transformerRef} ] on $fromPair")
}
}
if (transformerRegistration == TransformerRegistration.EMPTY) {
Expand All @@ -278,6 +280,11 @@ class ShapeShift(
return TransformerRegistration.EMPTY
} else {
transformerRegistration = getTransformerByType(annotation.transformer.java)
if (transformerRegistration != TransformerRegistration.EMPTY) {
log.trace("Found transformer by type [ ${annotation.transformer.java} ]")
} else {
error("Could not find transformer by type [ ${annotation.transformer.java} ] on $fromPair")
}
}
}
return transformerRegistration
Expand Down

0 comments on commit a0120f8

Please sign in to comment.