orika-mapper/orika

Running into a compilation error: bad method with a nested Map in a List

Opened this issue · 0 comments

While trying to map a String into a Map nested into a List nested into a Map, I'm running into a compilation error: bad method. I use this in-line property definition:

line:{|put('line', %s)|type=List}.map0:{|add(0,%s)|type=Map}.detailType:{|put('detailType', %s)|type=String}

This seems to be the code generated:

public void mapAtoB(java.lang.Object a, java.lang.Object b, ma.glasnost.orika.MappingContext mappingContext) {

        super.mapAtoB(a, b, mappingContext);


        // sourceType: Map<Object, Object>
        java.util.Map source = ((java.util.Map) a);
        // destinationType: Map<Object, Object>
        java.util.Map destination = ((java.util.Map) b);

        if (!(((java.lang.String) source.get("detailType")) == null)) {

            if ((((java.util.List) destination.get("line")) == null)) {

                destination.put("line", ((java.util.List) ((ma.glasnost.orika.BoundMapperFacade) usedMapperFacades[0]).newObject(((java.lang.String) source.get("detailType")), mappingContext)));
            }
            if ((null == null)) {

                ((java.util.List) destination.get("line")).add(((java.util.Map) ((ma.glasnost.orika.BoundMapperFacade) usedMapperFacades[1]).newObject(((java.lang.String) source.get("detailType")), mappingContext)));
            }
        }

        if (!(((java.lang.String) source.get("detailType")) == null)) {
            null.put("detailType", ((java.lang.String) source.get("detailType")));
        } else if (!(((java.util.List) destination.get("line")) == null) && !(null == null)) {
            null.put("detailType", null);
        }
        if (customMapper != null) {
            customMapper.mapAtoB(source, destination, mappingContext);
        }

    }

The line null.put("detailType", ((java.lang.String) source.get("detailType"))) has caught my attention and looks like a bug. Would there be any workaround?