From a16e62f4bd47da379c2aec5af33b28074c178d73 Mon Sep 17 00:00:00 2001 From: Florian Steurer Date: Tue, 12 Apr 2016 11:18:55 +0200 Subject: [PATCH] refactoring and commenting --- .../unify/model/ExtendsType.java | 11 +++++----- .../typeinference/unify/model/SuperType.java | 20 ++++++++++++++----- .../unify/model/WildcardType.java | 8 ++++++++ 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/ExtendsType.java b/src/de/dhbwstuttgart/typeinference/unify/model/ExtendsType.java index 9416d786..d5490e96 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/ExtendsType.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/ExtendsType.java @@ -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)); diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/SuperType.java b/src/de/dhbwstuttgart/typeinference/unify/model/SuperType.java index 7c557ade..8a828156 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/SuperType.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/SuperType.java @@ -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)); diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java b/src/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java index 9db59498..19efd88a 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java @@ -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;