1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.sf.jdiskcatalog.model;
24
25 import java.util.Collection;
26 import java.util.HashMap;
27 import java.util.Map;
28
29 import net.sf.jdiskcatalog.api.MutableNodeInfo;
30
31
32 public class NodeInfoImpl implements MutableNodeInfo
33 {
34 private Type type;
35
36 private String name;
37
38 private Map<String, Object> properties = new HashMap<String, Object>();
39
40 public NodeInfoImpl(String name, Type type)
41 {
42 this.type = type;
43 this.name = name;
44 }
45
46 public String getName()
47 {
48 return name;
49 }
50
51 public Type getType()
52 {
53 return type;
54 }
55
56 public Object getProperty(String name)
57 {
58 return properties.get(name);
59 }
60
61 public <T> T getProperty(String name, T defaultValue)
62 {
63 @SuppressWarnings("unchecked")
64 T value = (T)properties.get(name);
65 if (value == null)
66 value = defaultValue;
67 return value;
68 }
69
70 @Override
71 public String toString()
72 {
73 return getName();
74 }
75
76 public void setProperty(String name, Object value)
77 {
78 properties.put(name, value);
79 }
80
81 public boolean hasProperty(String name)
82 {
83 return properties.containsKey(name);
84 }
85
86 public Collection<String> getProperties()
87 {
88 return properties.keySet();
89 }
90 }