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/SimpleDirectory.java | |
| parent | 5832ef0286430d04484b70d49c73e081a80ec9c7 (diff) | |
Add more toString/hashCode/equals
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/esodata/SimpleDirectory.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/esodata/SimpleDirectory.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/esodata/SimpleDirectory.java b/BJC-Utils2/src/main/java/bjc/utils/esodata/SimpleDirectory.java index 3c1ced5..741b33d 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/esodata/SimpleDirectory.java +++ b/BJC-Utils2/src/main/java/bjc/utils/esodata/SimpleDirectory.java @@ -57,4 +57,47 @@ public class SimpleDirectory<K, V> implements Directory<K, V> { public V putKey(K key, V val) { 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; + + SimpleDirectory<?, ?> other = (SimpleDirectory<?, ?>) 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("SimpleDirectory [children="); + builder.append(children); + builder.append(", data="); + builder.append(data); + builder.append("]"); + + return builder.toString(); + } }
\ No newline at end of file |
