Introduce ? extends to the map of TPH. This should prevent an editing

This commit is contained in:
Till Schnell 2021-04-10 11:09:16 +02:00
parent de62df00e0
commit 077bd62b92
4 changed files with 15 additions and 5 deletions

View File

@ -37,7 +37,8 @@ public final class ConstraintsGenerationUtils
* @return The same instance {@code constraints} provided including the merged
* constraints
*/
public static ConstraintSet<Pair> generateAndMergeConstraints (Map<TypePlaceholder, RefType> tphMap,
public static ConstraintSet<Pair> generateAndMergeConstraints (
Map<? extends TypePlaceholder, ? extends RefType> tphMap,
ConstraintSet<Pair> constraints) {
ConstraintSet<Pair> generateConstraints = ConstraintsGenerationUtils.generateConstraints(tphMap);
constraints.addAll(generateConstraints);
@ -51,7 +52,7 @@ public final class ConstraintsGenerationUtils
* @return {@link ConstraintSet} of {@link Pair} containing the constraints to
* infer the matching wildcard type.
*/
public static ConstraintSet<Pair> generateConstraints (Map<TypePlaceholder, RefType> tphMap) {
public static ConstraintSet<Pair> generateConstraints (Map<? extends TypePlaceholder, ? extends RefType> tphMap) {
ConstraintSet<Pair> constraintSet = new ConstraintSet<>();
tphMap.forEach( (tph, refType) -> {
ConstraintSet<Pair> constraintSet2 = generateConstraints(refType, tph);

View File

@ -33,7 +33,7 @@ public class JavaTXCompilerWildcards
/**
* Generated Type placeholder and the implementation type represented.
*/
private final Map<TypePlaceholder, RefType> tphMap;
private final Map<? extends TypePlaceholder, ? extends RefType> tphMap;
public JavaTXCompilerWildcards (File... sourceFile) throws IOException, ClassNotFoundException {
super(sourceFile);
@ -56,6 +56,15 @@ public class JavaTXCompilerWildcards
this.tphMap = TypePlaceholderReplaceUtils.generateTypePlaceholder(this);
}
/**
* Return the Type Placeholder generated.
*
* @return {@link Map} over {@link TypePlaceholder} and {@link RefType}
*/
public Map<? extends TypePlaceholder, ? extends RefType> getTphMap () {
return tphMap;
}
@Override
public ConstraintSet<Pair> getConstraints () throws ClassNotFoundException, IOException {
ConstraintSet<Pair> constraints = super.getConstraints();

View File

@ -89,7 +89,7 @@ public class ReplaceTypeparamVisitor
*
* @return {@link Map} of {@link TypePlaceholder} and {@link RefType}
*/
public Map<TypePlaceholder, RefType> getTphMap () {
public Map<? extends TypePlaceholder, ? extends RefType> getTphMap () {
return tphMap;
}
}

View File

@ -30,7 +30,7 @@ public final class TypePlaceholderReplaceUtils
* @return {@link Map} over {@link TypePlaceholder} and the {@link RefType}
* replaced
*/
public static Map<TypePlaceholder, RefType> generateTypePlaceholder (JavaTXCompiler compiler) {
public static Map<? extends TypePlaceholder, ? extends RefType> generateTypePlaceholder (JavaTXCompiler compiler) {
Map<File, SourceFile> sourceFiles = compiler.getSourceFiles();
ReplaceTypeparamVisitor visitor = new ReplaceTypeparamVisitor();
sourceFiles.forEach( (k, v) -> v.accept(visitor));