From a0120f8d798d4361d61bd729cf526622cdec1643 Mon Sep 17 00:00:00 2001 From: Idan Elhalwani Date: Wed, 4 May 2022 09:57:07 +0300 Subject: [PATCH] feat: throw exception if transformer was not found --- src/main/java/dev/krud/shapeshift/ShapeShift.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/krud/shapeshift/ShapeShift.kt b/src/main/java/dev/krud/shapeshift/ShapeShift.kt index 539d58c..26ceaa7 100644 --- a/src/main/java/dev/krud/shapeshift/ShapeShift.kt +++ b/src/main/java/dev/krud/shapeshift/ShapeShift.kt @@ -254,7 +254,7 @@ class ShapeShift( fromPair: ObjectFieldTrio, toPair: ObjectFieldTrio ): TransformerRegistration<*, *> { - val transformationPair = Pair(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") @@ -262,7 +262,9 @@ class ShapeShift( 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) { @@ -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