atos1990 / orika

Automatically exported from code.google.com/p/orika
0 stars 0 forks source link

lookupConcreteDestinationType should return the most specific type, not the first that is assignable #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Have a class A that maps to both B and BSuper where B is a subclass of BSuper
2. call lookupConcreteDestinationType with destination B
3. depending on set iteration order, B or BSuper is returned

What is the expected output? What do you see instead?

I would expect it to return the tightest match, rather than the first that is 
assignable.

What version of the product are you using? On what operating system?

1.2.0 on Ubuntu with Java(TM) SE Runtime Environment (build 1.6.0_26-b03)

Please provide any additional information below.

Attached a failing test, the troublesome code is here

        for (final Type<?> type : destinationSet) {
            if (destinationType.isAssignableFrom(type) && ClassUtil.isConcrete(type)) {
                return (Type<? extends D>) type;
            }
        }

if destinationSet has multiple types that are assignable, it should pick the 
one that is the tightest fit, rather than the first one that matches

Original issue reported on code.google.com by ransombr...@gmail.com on 7 Jun 2012 at 6:59

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by elaat...@gmail.com on 9 Jun 2012 at 5:32

GoogleCodeExporter commented 9 years ago
Fixed in the current 1.2.0 branch

Original comment by matt.deb...@gmail.com on 9 Jul 2012 at 1:58