refactoring and commenting

This commit is contained in:
Florian Steurer 2016-04-12 11:18:55 +02:00
parent ea32cd5680
commit a16e62f4bd
3 changed files with 29 additions and 10 deletions

View File

@ -17,15 +17,16 @@ public final class ExtendsType extends WildcardType {
super("? extends " + extendedType.getName(), extendedType);
}
/**
* The extended type e.g. Integer in "? extends Integer"
*/
public UnifyType getExtendedType() {
return wildcardedType;
}
@Override
public TypeParams getTypeParams() {
return wildcardedType.getTypeParams();
}
/**
* Sets the type parameters of the wildcarded type and returns a new extendstype that extends that type.
*/
@Override
public UnifyType setTypeParams(TypeParams newTp) {
return new ExtendsType(wildcardedType.setTypeParams(newTp));

View File

@ -4,11 +4,23 @@ import java.util.Set;
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
/**
* A super wildcard type e.g. ? super Integer.
* @author Florian Steurer
*/
public final class SuperType extends WildcardType {
/**
* Creates a new instance "? extends superedType"
* @param superedType The type that is supered e.g. Integer in "? super Integer"
*/
public SuperType(UnifyType superedType) {
super("? super " + superedType.getName(), superedType);
}
/**
* The type that is supered e.g. Integer in "? super Integer"
*/
public UnifyType getSuperedType() {
return wildcardedType;
}
@ -18,11 +30,9 @@ public final class SuperType extends WildcardType {
return "? super " + wildcardedType;
}
@Override
public TypeParams getTypeParams() {
return wildcardedType.getTypeParams();
}
/**
* Sets the type parameters of the wildcarded type and returns a new supertype that supers that type.
*/
@Override
public UnifyType setTypeParams(TypeParams newTp) {
return new SuperType(wildcardedType.setTypeParams(newTp));

View File

@ -29,6 +29,14 @@ public abstract class WildcardType extends UnifyType {
return wildcardedType;
}
/**
* Returns the type parameters of the WILDCARDED TYPE.
*/
@Override
public TypeParams getTypeParams() {
return wildcardedType.getTypeParams();
}
@Override
public int hashCode() {
return wildcardedType.hashCode() + getName().hashCode() + 17;