1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.yaml.snakeyaml;
17
18 import java.util.HashMap;
19 import java.util.Map;
20
21 import org.yaml.snakeyaml.nodes.Tag;
22
23
24
25
26
27 public final class TypeDescription {
28 private final Class<? extends Object> type;
29 private Tag tag;
30 private Map<String, Class<? extends Object>> listProperties;
31 private Map<String, Class<? extends Object>> keyProperties;
32 private Map<String, Class<? extends Object>> valueProperties;
33
34 public TypeDescription(Class<? extends Object> clazz, Tag tag) {
35 this.type = clazz;
36 this.tag = tag;
37 listProperties = new HashMap<String, Class<? extends Object>>();
38 keyProperties = new HashMap<String, Class<? extends Object>>();
39 valueProperties = new HashMap<String, Class<? extends Object>>();
40 }
41
42 public TypeDescription(Class<? extends Object> clazz, String tag) {
43 this(clazz, new Tag(tag));
44 }
45
46 public TypeDescription(Class<? extends Object> clazz) {
47 this(clazz, (Tag) null);
48 }
49
50
51
52
53
54
55
56 public Tag getTag() {
57 return tag;
58 }
59
60
61
62
63
64
65
66 public void setTag(Tag tag) {
67 this.tag = tag;
68 }
69
70 public void setTag(String tag) {
71 setTag(new Tag(tag));
72 }
73
74
75
76
77
78
79 public Class<? extends Object> getType() {
80 return type;
81 }
82
83
84
85
86
87
88
89
90
91 public void putListPropertyType(String property, Class<? extends Object> type) {
92 listProperties.put(property, type);
93 }
94
95
96
97
98
99
100
101
102 public Class<? extends Object> getListPropertyType(String property) {
103 return listProperties.get(property);
104 }
105
106
107
108
109
110
111
112
113
114
115
116 public void putMapPropertyType(String property, Class<? extends Object> key,
117 Class<? extends Object> value) {
118 keyProperties.put(property, key);
119 valueProperties.put(property, value);
120 }
121
122
123
124
125
126
127
128
129 public Class<? extends Object> getMapKeyType(String property) {
130 return keyProperties.get(property);
131 }
132
133
134
135
136
137
138
139
140 public Class<? extends Object> getMapValueType(String property) {
141 return valueProperties.get(property);
142 }
143
144 @Override
145 public String toString() {
146 return "TypeDescription for " + getType() + " (tag='" + getTag() + "')";
147 }
148 }