timothyjward commented on code in PR #24:
URL: https://github.com/apache/aries-typedevent/pull/24#discussion_r1959932665


##########
org.apache.aries.typedevent.bus/src/main/java/org/apache/aries/typedevent/bus/impl/EventConverter.java:
##########
@@ -296,35 +297,41 @@ public Map<String, Object> toUntypedEvent() {
     }
 
     @SuppressWarnings("unchecked")
-       public <T> T toTypedEvent(TypeData targetEventClass) {
-        Class<?> rawType = targetEventClass.getRawType();
-        Type genericTarget = targetEventClass.getType();
-               if (rawType.isInstance(originalEvent) && rawType == 
genericTarget) {
-                       if(_log.isDebugEnabled()) {
-                       _log.debug("No need to convert {} to {} as it is 
already an instance", originalEvent, rawType);
-               }
-            return (T) originalEvent;
-        } else {
-               if(custom != null) {
-                       if(_log.isDebugEnabled()) {
-                               _log.debug("Using custom converter to convert 
{} to {}", originalEvent, genericTarget);
-                       }
-                               Object result = 
custom.toTypedEvent(originalEvent, rawType, genericTarget);
-                               if(result != null) {
-                                       return (T) result;
+       public <T> T toTypedEvent(TypeData typeData) {
+               Class<?> rawType = typeData.getRawType();
+               Type genericTarget = typeData.getType();
+               if (rawType.isInstance(originalEvent) && rawType == 
genericTarget && !typeData.isForceConversion()) {

Review Comment:
   Another, possibly better, option would be to have
   
   ```java
   if(typeDate.isForceConversion()) {
        if (_log.isDebugEnabled()) {
                _log.debug("Conversion is forced by property {}", 
TypeData.ARIES_EVENT_FORCE_CONVERSION);
        }
   } else if (rawType.isInstance(originalEvent) && rawType == genericTarget) {
        ...
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@aries.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to