Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array and Map paramter ignored as source-parameter if used as only source #173

Open
hduelme opened this issue Jan 28, 2024 · 0 comments
Open

Comments

@hduelme
Copy link
Contributor

hduelme commented Jan 28, 2024

I found while investigation #168, that currently the plugin ignores source parameters of type array and Map, if used as the only source parameter.
Here a small example Mapper:

import org.mapstruct.Mapper;

import java.util.Map;

@Mapper
public interface MultiSourceMapper {

    class ArrayTarget {
        private int[] myArray;

        public int[] getMyArray() {
            return myArray;
        }

        public void setMyArray(int[] myArray) {
            this.myArray = myArray;
        }
    }

    ArrayTarget mapToArrayTarget(int[] myArray);

    class MapTarget {
        private Map<Integer, Integer> myMap;

        public Map<Integer, Integer> getMyMap() {
            return myMap;
        }

        public void setMyMap(Map<Integer, Integer> myMap) {
            this.myMap = myMap;
        }
    }

    MapTarget mapToMapTarget(Map<Integer, Integer> myMap);
}

This generates code where all targets are mapped based on their names. The plugin currently ignores the source parameters and give a unmapped target property warning.
grafik
Also the completion doesn't show them as source parameters.

One thing to notice:
For Iterable this behavior is correct as mapstruct itself doesn't support mapping from Iterable to Object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant