From df4faebd925e014d7de61e1fb84ba5b1a6ed6570 Mon Sep 17 00:00:00 2001 From: Etienne Zink Date: Sat, 19 Mar 2022 18:16:50 +0100 Subject: [PATCH] =?UTF-8?q?Hinzuf=C3=BCgen=20der=20extends-Beziehung=20von?= =?UTF-8?q?=20IntermediateExtendsWildcard=20und=20IntermediateSuperWildcar?= =?UTF-8?q?d=20zu=20IntermediateType,=20ohne=20Implementierungen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../types/IntermediateExtendsWildcard.java | 26 ++++++++- .../types/IntermediateGenericType.java | 36 ++++++------- .../types/IntermediateRefType.java | 54 +++++++++---------- .../types/IntermediateSuperWildcard.java | 26 ++++++++- 4 files changed, 95 insertions(+), 47 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateExtendsWildcard.java b/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateExtendsWildcard.java index b4f57597..eda1eafd 100644 --- a/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateExtendsWildcard.java +++ b/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateExtendsWildcard.java @@ -8,6 +8,30 @@ import de.dhbwstuttgart.parser.scope.JavaClassName; * @since Studienarbeit Type Erasure * @author etiennezink */ -public final class IntermediateExtendsWildcard { +public final class IntermediateExtendsWildcard extends IntermediateType { //ToDo + + public IntermediateExtendsWildcard(JavaClassName className) { + super(className); + } + + @Override + public boolean equals(Object o) { + return false; + } + + @Override + public int hashCode() { + return 0; + } + + @Override + public String getSignature() { + return null; + } + + @Override + public String getDescriptor() { + return null; + } } diff --git a/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateGenericType.java b/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateGenericType.java index 053cd0db..9a36e566 100644 --- a/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateGenericType.java +++ b/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateGenericType.java @@ -38,24 +38,6 @@ public final class IntermediateGenericType extends IntermediateType { this.genericName = genericName; } - @Override - public String getSignature() { - String signature = this.signature; - if (!signature.equals("")) return this.signature; - signature += String.format("T%s;", genericName); - this.signature = signature; - return signature; - } - - @Override - public String getDescriptor() { - String descriptor = this.descriptor; - if (!descriptor.equals("")) return this.descriptor; - descriptor = String.format("L%s;", getFullyQualifiedName()).replace('.','/'); - this.descriptor = descriptor; - return descriptor; - } - @Override public boolean equals(Object o) { if (!(o instanceof IntermediateGenericType)) return false; @@ -78,6 +60,24 @@ public final class IntermediateGenericType extends IntermediateType { return result; } + @Override + public String getSignature() { + String signature = this.signature; + if (!signature.equals("")) return this.signature; + signature += String.format("T%s;", genericName); + this.signature = signature; + return signature; + } + + @Override + public String getDescriptor() { + String descriptor = this.descriptor; + if (!descriptor.equals("")) return this.descriptor; + descriptor = String.format("L%s;", getFullyQualifiedName()).replace('.','/'); + this.descriptor = descriptor; + return descriptor; + } + public String getGenericName() { return genericName; } diff --git a/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateRefType.java b/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateRefType.java index f8b908b9..c121becb 100644 --- a/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateRefType.java +++ b/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateRefType.java @@ -39,6 +39,33 @@ public final class IntermediateRefType extends IntermediateType{ this.typParameters = Collections.unmodifiableList(typParameters); } + @Override + public boolean equals(Object o) { + if (!(o instanceof IntermediateRefType)) return false; + + IntermediateRefType intermediateRefType = (IntermediateRefType) o; + if(!getFullyQualifiedName().equals(intermediateRefType.getFullyQualifiedName())) return false; + + for(int index = 0; index < typParameters.size(); index++){ + if(!typParameters.get(index).equals(intermediateRefType.typParameters.get(index))) return false; + } + return true; + } + + @Override + public int hashCode() { + int prime = 31; + int result = hashCode; + if (result == 0){ + result += getFullyQualifiedName().hashCode(); + for (IntermediateType typeParameter:typParameters) { + result = prime * result + typeParameter.hashCode(); + } + hashCode = result; + } + return result; + } + @Override public String getSignature() { String signature = this.signature; @@ -70,33 +97,6 @@ public final class IntermediateRefType extends IntermediateType{ return descriptor; } - @Override - public boolean equals(Object o) { - if (!(o instanceof IntermediateRefType)) return false; - - IntermediateRefType intermediateRefType = (IntermediateRefType) o; - if(!getFullyQualifiedName().equals(intermediateRefType.getFullyQualifiedName())) return false; - - for(int index = 0; index < typParameters.size(); index++){ - if(!typParameters.get(index).equals(intermediateRefType.typParameters.get(index))) return false; - } - return true; - } - - @Override - public int hashCode() { - int prime = 31; - int result = hashCode; - if (result == 0){ - result += getFullyQualifiedName().hashCode(); - for (IntermediateType typeParameter:typParameters) { - result = prime * result + typeParameter.hashCode(); - } - hashCode = result; - } - return result; - } - public int getTypParameterSize(){ return typParameters.size(); } /** diff --git a/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateSuperWildcard.java b/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateSuperWildcard.java index 1fe48ace..42fdaf37 100644 --- a/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateSuperWildcard.java +++ b/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateSuperWildcard.java @@ -8,6 +8,30 @@ import de.dhbwstuttgart.parser.scope.JavaClassName; * @since Studienarbeit Type Erasure * @author etiennezink */ -public final class IntermediateSuperWildcard { +public final class IntermediateSuperWildcard extends IntermediateType { //ToDo + + public IntermediateSuperWildcard(JavaClassName className) { + super(className); + } + + @Override + public boolean equals(Object o) { + return false; + } + + @Override + public int hashCode() { + return 0; + } + + @Override + public String getSignature() { + return null; + } + + @Override + public String getDescriptor() { + return null; + } }