Skip to content

Do not emit warning for unused source parameters of Map type #3861

Description

@csisy

Expected behavior

Do not emit warning for a Map<> parameter that is not used for property mapping, only in expressions.

Actual behavior

See repro steps:

The Map parameter "values" cannot be used for property mapping. It must be typed with Map<String, ???> but it was typed with Map<Integer,Integer>

Steps to reproduce the problem

Here is an oversimplified example:

public record Target(String foo, Integer sum) {}

@Mapper
public interface MyMapper {

	MyMapper instance = Mappers.getMapper(MyMapper.class);

	@Mapping(target = "sum", expression = "java(calculateSum(values))")
	Target map(String foo, Map<Integer, Integer> values);

	default int calculateSum(Map<Integer, Integer> values) {
		return values.values()
				.stream()
				.reduce(0, Integer::sum);
	}
}

MapStruct Version

1.6.3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions