From 63d88eb8db1f7a6d5924ec2a8b7f462373d5ac9a Mon Sep 17 00:00:00 2001 From: bjculkin Date: Fri, 7 Apr 2017 10:51:31 -0400 Subject: Cleanup --- .../java/bjc/utils/esodata/UnifiedDirectory.java | 49 ++++++++++++---------- 1 file changed, 27 insertions(+), 22 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/esodata/UnifiedDirectory.java') 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 61ec72b..a0d9096 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/esodata/UnifiedDirectory.java +++ b/BJC-Utils2/src/main/java/bjc/utils/esodata/UnifiedDirectory.java @@ -40,8 +40,11 @@ public class UnifiedDirectory implements Directory { @Override public Directory putSubdirectory(K key, Directory val) { - if(data.containsKey(key)) - throw new IllegalArgumentException("Key " + key + " is already used for data."); + if (data.containsKey(key)) { + String msg = String.format("Key %s is already used for data", key); + + throw new IllegalArgumentException(msg); + } return children.put(key, val); } @@ -58,8 +61,11 @@ public class UnifiedDirectory implements Directory { @Override public V putKey(K key, V val) { - if(children.containsKey(key)) - throw new IllegalArgumentException("Key " + key + " is already used for sub-directories."); + if (children.containsKey(key)) { + String msg = String.format("Key %s is already used for sub-directories.", key); + + throw new IllegalArgumentException(msg); + } return data.put(key, val); } @@ -75,33 +81,32 @@ public class UnifiedDirectory implements Directory { @Override public boolean equals(Object obj) { - if(this == obj) return true; - if(obj == null) return false; - if(getClass() != obj.getClass()) return false; + if (this == obj) + return true; + if (obj == null) + return false; + if (!(obj instanceof UnifiedDirectory)) + return false; UnifiedDirectory other = (UnifiedDirectory) obj; - if(children == null) { - if(other.children != null) return false; - } else if(!children.equals(other.children)) return false; + 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; + 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(); + return String.format("UnifiedDirectory [children=%s, data=%s]", children, data); } } \ No newline at end of file -- cgit v1.2.3