diff options
Diffstat (limited to 'st/ClassInstance.java')
-rw-r--r-- | st/ClassInstance.java | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/st/ClassInstance.java b/st/ClassInstance.java index d96d3d5..a794f96 100644 --- a/st/ClassInstance.java +++ b/st/ClassInstance.java @@ -1,6 +1,7 @@ package st; import java.util.ArrayList; +import misc.*; public class ClassInstance extends AbstractInstance { private ClassInstance ext; // the name of the extended class (null if none) @@ -15,8 +16,29 @@ public class ClassInstance extends AbstractInstance { @Override public boolean equals(Object other) { ClassInstance o; - return (other instanceof ClassInstance && - ((o = (ClassInstance) other).getName() == this.getName())); + if (other instanceof ClassInstance) + o = (ClassInstance) other; + else + return false; + + if (o.getName().equals(this.getName())) + return true; + else + MinimalLogger.info(String.format("I (%s) do not have the same name as %s... Checking if I extend...", + this.getName(), o.getName())); + + if (this.getExtend() == null) { + MinimalLogger.info(String.format("I (%s) do not extend anything!", this.getName())); + return false; + } + + ClassInstance te = this.getExtend(); + if (te.equals(o)) { + MinimalLogger.info(String.format("I (%s) extends %s!", this.getName(), o.getName())); + return true; + } + MinimalLogger.info(String.format("I (%s) do not extend %s! I extend %s instead.", this.getName(), o.getName(), te.getName())); + return false; } public ClassInstance getExtend() { |