diff options
| author | bjculkin <bjculkin@mix.wvu.edu> | 2017-03-17 19:46:55 -0400 |
|---|---|---|
| committer | bjculkin <bjculkin@mix.wvu.edu> | 2017-03-17 19:46:55 -0400 |
| commit | 338b2b16b6934d27dc4cd536fb5527b71985de4f (patch) | |
| tree | 6dc7e85370507d22150cd7cef353a033b50a71d7 /BJC-Utils2/src/main/java/bjc/utils/esodata/UnifiedDirectory.java | |
| parent | 5832ef0286430d04484b70d49c73e081a80ec9c7 (diff) | |
Add more toString/hashCode/equals
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/esodata/UnifiedDirectory.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/esodata/UnifiedDirectory.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/esodata/UnifiedDirectory.java b/BJC-Utils2/src/main/java/bjc/utils/esodata/UnifiedDirectory.java index d4c5081..61ec72b 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/esodata/UnifiedDirectory.java +++ b/BJC-Utils2/src/main/java/bjc/utils/esodata/UnifiedDirectory.java @@ -63,4 +63,45 @@ public class UnifiedDirectory<K, V> implements Directory<K, V> { return data.put(key, val); } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((children == null) ? 0 : children.hashCode()); + result = prime * result + ((data == null) ? 0 : data.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if(this == obj) return true; + if(obj == null) return false; + if(getClass() != obj.getClass()) return false; + + UnifiedDirectory<?, ?> other = (UnifiedDirectory<?, ?>) obj; + + if(children == null) { + if(other.children != null) return false; + } else if(!children.equals(other.children)) return false; + + if(data == null) { + if(other.data != null) return false; + } else if(!data.equals(other.data)) return false; + + return true; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + + builder.append("UnifiedDirectory [children="); + builder.append(children); + builder.append(", data="); + builder.append(data); + builder.append("]"); + + return builder.toString(); + } }
\ No newline at end of file |
