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