forked from JavaTX/JavaCompilerCore
Simplify generateConstraints
This commit is contained in:
parent
76a291ab41
commit
fd7628cb40
@ -2,6 +2,7 @@ package de.dhbwstuttgart.inferWildcards;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import de.dhbwstuttgart.parser.NullToken;
|
import de.dhbwstuttgart.parser.NullToken;
|
||||||
@ -55,12 +56,27 @@ public final class ConstraintsGenerationUtils
|
|||||||
*/
|
*/
|
||||||
public static ConstraintSet<Pair> generateConstraints (
|
public static ConstraintSet<Pair> generateConstraints (
|
||||||
Map<? extends TypePlaceholder, ? extends RefTypeOrTPHOrWildcardOrGeneric> tphMap) {
|
Map<? extends TypePlaceholder, ? extends RefTypeOrTPHOrWildcardOrGeneric> tphMap) {
|
||||||
ConstraintSet<Pair> constraintSet = new ConstraintSet<>();
|
return tphMap.entrySet().stream().map(ConstraintsGenerationUtils::generateConstraints)
|
||||||
tphMap.forEach( (tph, refType) -> {
|
.reduce(
|
||||||
ConstraintSet<Pair> constraintSet2 = generateConstraints(refType, tph);
|
new ConstraintSet<>(),
|
||||||
constraintSet.addAll(constraintSet2);
|
(cs, c) -> {
|
||||||
|
cs.addAll(c);
|
||||||
|
return cs;
|
||||||
});
|
});
|
||||||
return constraintSet;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the constraints for a single RefType type placeholder pair to infer
|
||||||
|
* the wildcards for the generic parameter type.
|
||||||
|
*
|
||||||
|
* @param tphEntry {@link Entry} of {@link TypePlaceholder} and
|
||||||
|
* {@link RefTypeOrTPHOrWildcardOrGeneric}
|
||||||
|
* @return {@link ConstraintSet} of {@link Pair} generated containing the
|
||||||
|
* constraints.
|
||||||
|
*/
|
||||||
|
private static ConstraintSet<Pair> generateConstraints (
|
||||||
|
Map.Entry<? extends TypePlaceholder, ? extends RefTypeOrTPHOrWildcardOrGeneric> tphEntry) {
|
||||||
|
return generateConstraints(tphEntry.getValue(), tphEntry.getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user