Added toString for debugging and error logging and Cloneable.

This commit is contained in:
Kevin Ruland 2012-04-02 20:05:53 +00:00
parent 340bf068ce
commit 2c793422b5

View File

@ -6,7 +6,7 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
public class TypedPropertyMap { public class TypedPropertyMap implements Cloneable {
private final Map<TypedKey<?>, Object> delegate; private final Map<TypedKey<?>, Object> delegate;
@ -66,5 +66,21 @@ public class TypedPropertyMap {
public Set<Entry<TypedKey<?>, Object>> entrySet() { public Set<Entry<TypedKey<?>, Object>> entrySet() {
return delegate.entrySet(); return delegate.entrySet();
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TypedPropertyMap: { ");
for( Map.Entry<TypedKey<?>, Object> e : delegate.entrySet() ) {
sb.append(e.getKey()).append(" => ").append(String.valueOf(e.getValue()));
}
sb.append("}");
return sb.toString();
}
@Override
protected TypedPropertyMap clone() throws CloneNotSupportedException {
TypedPropertyMap clone = new TypedPropertyMap();
clone.putAll(this);
return clone;
}
} }