I have the following code:
private Set<? extends DecisionGroupDto> parentGroups = new HashSet<>();
public DecisionDto(Decision decision) {
super(decision);
if (decision != null) {
Set<? extends DecisionGroup> parentGroups = decision.getParentGroups();
if (CollectionUtils.isNotEmpty(parentGroups)) {
for (DecisionGroup parentGroup : parentGroups) {
this.parentGroups.add(new DecisionGroupDto(parentGroup));
}
}
}
}
right now the following line:
this.parentGroups.add(new DecisionGroupDto(parentGroup));
fails with the following error:
Required type: capture of ? extends DecisionGroupDto
Provided:DecisionGroupDto
How to allow this.parentGroups
accept not only derived classes from DecisionGroupDto
but also and DecisionGroupDto
itself?