create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / preset / TypedPropertyMap.java
1 package net.sf.openrocket.preset;
2
3 import java.util.Collection;
4 import java.util.LinkedHashMap;
5 import java.util.Map;
6 import java.util.Map.Entry;
7 import java.util.Set;
8
9 public class TypedPropertyMap implements Cloneable {
10         
11         private final Map<TypedKey<?>, Object> delegate;
12         
13         public TypedPropertyMap() {
14                 delegate = new LinkedHashMap<TypedKey<?>, Object>();
15         }
16         
17         public int size() {
18                 return delegate.size();
19         }
20         
21         public boolean isEmpty() {
22                 return delegate.isEmpty();
23         }
24         
25         public boolean containsKey(Object key) {
26                 return delegate.containsKey(key);
27         }
28         
29         public boolean containsValue(Object value) {
30                 return delegate.containsValue(value);
31         }
32         
33         @SuppressWarnings("unchecked")
34         public <T> T get(TypedKey<T> key) {
35                 return (T) delegate.get(key);
36         }
37         
38         @SuppressWarnings("unchecked")
39         public <T> T put(TypedKey<T> key, T value) {
40                 return (T) delegate.put(key, value);
41         }
42         
43         public Object remove(Object key) {
44                 return delegate.remove(key);
45         }
46         
47         public void putAll(TypedPropertyMap other) {
48                 if (other == null) {
49                         return;
50                 }
51                 delegate.putAll(other.delegate);
52         }
53         
54         public void clear() {
55                 delegate.clear();
56         }
57         
58         public Set<TypedKey<?>> keySet() {
59                 return delegate.keySet();
60         }
61         
62         public Collection<Object> values() {
63                 return delegate.values();
64         }
65         
66         public Set<Entry<TypedKey<?>, Object>> entrySet() {
67                 return delegate.entrySet();
68         }
69         @Override
70         public String toString() {
71                 StringBuilder sb = new StringBuilder("TypedPropertyMap: { ");
72                 for( Map.Entry<TypedKey<?>, Object> e : delegate.entrySet() ) {
73                         sb.append(e.getKey()).append(" => ").append(String.valueOf(e.getValue()));
74                 }
75                 sb.append("}");
76                 return sb.toString();
77         }
78
79         @Override
80         protected TypedPropertyMap clone() throws CloneNotSupportedException {
81                 TypedPropertyMap clone = new TypedPropertyMap();
82                 clone.putAll(this);
83                 return clone;
84         }
85         
86 }