Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

New mapping feature not support property paths #2553

Copy link
Copy link
@jonsalvas

Description

@jonsalvas
Issue body actions

First of all: thanks for the great job you are doing with this library, it helps us to save a lot of boilerplate code. I was really happy that you finally released the feature to map maps to beans: https://mapstruct.org/documentation/dev/reference/html/#mapping-map-to-bean
As we use a lot of maps in our project it will be very helpful.

However, I was not really able to make it work in our project so I tried to build a minimal example based on one of your test cases (MapToBeanFromMultipleSource) in the PR. There I noticed that, if the map is a field of a bean the property path in the source parameter is not resolved correctly. Minimized example code:

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.Map;

@Mapper
public interface MapToBeanFromMultipleSources {
    @Mapping(target = "string", source = "bean.strings.string")
    Target toTarget(Source bean);

    class Source {
        private Map<String, String> strings;

        public Map<String, String> getStrings() {
            return strings;
        }

        public void setStrings(Map<String, String> strings) {
            this.strings = strings;
        }

    }

    class Target {

        private String string;


        public String getString() {
            return string;
        }

        public void setString(String string) {
            this.string = string;
        }

    }
}

I am receiving: "The type of parameter "bean" has no property named "strings.string". Am I missing something, or is this currently not supported?

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.