remove raw types and add java doc
This commit is contained in:
parent
5f7829191c
commit
11b63e0a5d
@ -15,6 +15,12 @@ import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||
|
||||
/**
|
||||
* Utilities to generate the constraints for the infer wildcards algorithm.
|
||||
*
|
||||
* @author Till Schnell
|
||||
* @version 1.0
|
||||
*/
|
||||
public final class ConstraintsGenerationUtils
|
||||
{
|
||||
|
||||
@ -22,23 +28,37 @@ public final class ConstraintsGenerationUtils
|
||||
throw new AssertionError("No ConstraintsGenerationUtils instance for you");
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static ConstraintSet generateConstraints (Map<TypePlaceholder, RefType> tphMap) {
|
||||
ConstraintSet constraintSet = new ConstraintSet<>();
|
||||
/**
|
||||
* Generate the constraints for a map of type placeholder and RefType.
|
||||
*
|
||||
* @param tphMap {@link Map} of {@link TypePlaceholder} and {@link RefType}
|
||||
* @return {@link ConstraintSet} of {@link Pair} containing the constraints to
|
||||
* infer the matching wildcard type.
|
||||
*/
|
||||
public static ConstraintSet<Pair> generateConstraints (Map<TypePlaceholder, RefType> tphMap) {
|
||||
ConstraintSet<Pair> constraintSet = new ConstraintSet<>();
|
||||
tphMap.forEach( (tph, refType) -> {
|
||||
ConstraintSet constraintSet2 = generateConstraints(refType, tph);
|
||||
ConstraintSet<Pair> constraintSet2 = generateConstraints(refType, tph);
|
||||
constraintSet.addAll(constraintSet2);
|
||||
});
|
||||
return constraintSet;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static ConstraintSet generateConstraints (RefType refType, TypePlaceholder tph) {
|
||||
ConstraintSet constraintSet = new ConstraintSet<>();
|
||||
Set<Constraint<?>> oderConstraints = new HashSet<>();
|
||||
/**
|
||||
* Generate the constraints for a single RefType type placeholder pair to infer
|
||||
* the wildcards for the generic parameter type.
|
||||
*
|
||||
* @param refType {@link RefType}
|
||||
* @param tph {@link TypePlaceholder}
|
||||
* @return {@link ConstraintSet} of {@link Pair} generated containing the
|
||||
* constraints.
|
||||
*/
|
||||
public static ConstraintSet<Pair> generateConstraints (RefType refType, TypePlaceholder tph) {
|
||||
ConstraintSet<Pair> constraintSet = new ConstraintSet<>();
|
||||
Set<Constraint<Pair>> oderConstraints = new HashSet<>();
|
||||
constraintSet.addOderConstraint(oderConstraints);
|
||||
|
||||
Constraint<?> c = new Constraint<>();
|
||||
Constraint<Pair> c = new Constraint<>();
|
||||
oderConstraints.add(c);
|
||||
|
||||
// single type
|
||||
@ -55,8 +75,15 @@ public final class ConstraintsGenerationUtils
|
||||
return constraintSet;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private static void addToConstraint (Constraint c, TypePlaceholder tph, RefTypeOrTPHOrWildcardOrGeneric type) {
|
||||
/**
|
||||
* Generate a pair and adds it to a constraint.
|
||||
*
|
||||
* @param c {@link Constraint} of {@link Pair}
|
||||
* @param tph {@link TypePlaceholder}
|
||||
* @param type {@link RefTypeOrTPHOrWildcardOrGeneric}
|
||||
*/
|
||||
private static void addToConstraint (Constraint<Pair> c, TypePlaceholder tph,
|
||||
RefTypeOrTPHOrWildcardOrGeneric type) {
|
||||
Pair pair = new Pair(tph, type, PairOperator.EQUALSDOT);
|
||||
c.add(pair);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user