From 8d25920a87792fcea0a9a1eabca03f5cd64ac9db Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Fri, 30 Oct 2020 15:44:46 +0100 Subject: [PATCH] Add Hashcode methods --- src/main/java/de/dhbwstuttgart/parser/scope/GatherNames.java | 2 +- .../de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java | 4 ++++ .../de/dhbwstuttgart/typeinference/unify/model/UnifyType.java | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/dhbwstuttgart/parser/scope/GatherNames.java b/src/main/java/de/dhbwstuttgart/parser/scope/GatherNames.java index 8e93355b..aec9f8b4 100644 --- a/src/main/java/de/dhbwstuttgart/parser/scope/GatherNames.java +++ b/src/main/java/de/dhbwstuttgart/parser/scope/GatherNames.java @@ -43,7 +43,7 @@ public class GatherNames { } else{ if(typeDecl.classDeclaration().normalClassDeclaration() != null){ - if(pkgName != ""){ + if(!pkgName.isEmpty()){ nameString = pkgName + "." + typeDecl.classDeclaration().normalClassDeclaration().Identifier().toString(); } else{ diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java b/src/main/java/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java index cdc204b0..66435b68 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java @@ -64,6 +64,10 @@ public class TypePlaceholder extends RefTypeOrTPHOrWildcardOrGeneric } } + @Override + public int hashCode() { + return this.getName().hashCode(); + } public String toString() { diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java index f7ded0a6..8d253092 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java @@ -114,6 +114,7 @@ public abstract class UnifyType { @Override public boolean equals(Object obj) { + if(obj == null)return false; return this.toString().equals(obj.toString()); } } \ No newline at end of file