summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/esodata/UnifiedDirectory.java
diff options
context:
space:
mode:
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.java49
1 files changed, 27 insertions, 22 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 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<K, V> implements Directory<K, V> {
@Override
public Directory<K, V> putSubdirectory(K key, Directory<K, V> 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<K, V> implements Directory<K, V> {
@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<K, V> implements Directory<K, V> {
@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