@@ -24,7 +24,7 @@ public enum XContentType implements MediaType {
24
24
/**
25
25
* A JSON based content type.
26
26
*/
27
- JSON (0 ) {
27
+ JSON (0 , JsonXContent . jsonXContent ) {
28
28
@ Override
29
29
public String mediaTypeWithoutParameters () {
30
30
return "application/json" ;
@@ -40,11 +40,6 @@ public String queryParameter() {
40
40
return "json" ;
41
41
}
42
42
43
- @ Override
44
- public XContent xContent () {
45
- return JsonXContent .jsonXContent ;
46
- }
47
-
48
43
@ Override
49
44
public Set <HeaderValue > headerValues () {
50
45
return Set .of (new HeaderValue ("application/json" ), new HeaderValue ("application/x-ndjson" ), new HeaderValue ("application/*" ));
@@ -53,7 +48,7 @@ public Set<HeaderValue> headerValues() {
53
48
/**
54
49
* The jackson based smile binary format. Fast and compact binary format.
55
50
*/
56
- SMILE (1 ) {
51
+ SMILE (1 , SmileXContent . smileXContent ) {
57
52
@ Override
58
53
public String mediaTypeWithoutParameters () {
59
54
return "application/smile" ;
@@ -64,11 +59,6 @@ public String queryParameter() {
64
59
return "smile" ;
65
60
}
66
61
67
- @ Override
68
- public XContent xContent () {
69
- return SmileXContent .smileXContent ;
70
- }
71
-
72
62
@ Override
73
63
public Set <HeaderValue > headerValues () {
74
64
return Set .of (new HeaderValue ("application/smile" ));
@@ -77,7 +67,7 @@ public Set<HeaderValue> headerValues() {
77
67
/**
78
68
* A YAML based content type.
79
69
*/
80
- YAML (2 ) {
70
+ YAML (2 , YamlXContent . yamlXContent ) {
81
71
@ Override
82
72
public String mediaTypeWithoutParameters () {
83
73
return "application/yaml" ;
@@ -88,11 +78,6 @@ public String queryParameter() {
88
78
return "yaml" ;
89
79
}
90
80
91
- @ Override
92
- public XContent xContent () {
93
- return YamlXContent .yamlXContent ;
94
- }
95
-
96
81
@ Override
97
82
public Set <HeaderValue > headerValues () {
98
83
return Set .of (new HeaderValue ("application/yaml" ));
@@ -101,7 +86,7 @@ public Set<HeaderValue> headerValues() {
101
86
/**
102
87
* A CBOR based content type.
103
88
*/
104
- CBOR (3 ) {
89
+ CBOR (3 , CborXContent . cborXContent ) {
105
90
@ Override
106
91
public String mediaTypeWithoutParameters () {
107
92
return "application/cbor" ;
@@ -112,11 +97,6 @@ public String queryParameter() {
112
97
return "cbor" ;
113
98
}
114
99
115
- @ Override
116
- public XContent xContent () {
117
- return CborXContent .cborXContent ;
118
- }
119
-
120
100
@ Override
121
101
public Set <HeaderValue > headerValues () {
122
102
return Set .of (new HeaderValue ("application/cbor" ));
@@ -125,7 +105,7 @@ public Set<HeaderValue> headerValues() {
125
105
/**
126
106
* A versioned JSON based content type.
127
107
*/
128
- VND_JSON (4 ) {
108
+ VND_JSON (4 , JsonXContent . jsonXContent ) {
129
109
@ Override
130
110
public String mediaTypeWithoutParameters () {
131
111
return VENDOR_APPLICATION_PREFIX + "json" ;
@@ -136,11 +116,6 @@ public String queryParameter() {
136
116
return "vnd_json" ;
137
117
}
138
118
139
- @ Override
140
- public XContent xContent () {
141
- return JsonXContent .jsonXContent ;
142
- }
143
-
144
119
@ Override
145
120
public Set <HeaderValue > headerValues () {
146
121
return Set .of (
@@ -157,7 +132,7 @@ public XContentType canonical() {
157
132
/**
158
133
* Versioned jackson based smile binary format. Fast and compact binary format.
159
134
*/
160
- VND_SMILE (5 ) {
135
+ VND_SMILE (5 , SmileXContent . smileXContent ) {
161
136
@ Override
162
137
public String mediaTypeWithoutParameters () {
163
138
return VENDOR_APPLICATION_PREFIX + "smile" ;
@@ -168,11 +143,6 @@ public String queryParameter() {
168
143
return "vnd_smile" ;
169
144
}
170
145
171
- @ Override
172
- public XContent xContent () {
173
- return SmileXContent .smileXContent ;
174
- }
175
-
176
146
@ Override
177
147
public Set <HeaderValue > headerValues () {
178
148
return Set .of (new HeaderValue (VENDOR_APPLICATION_PREFIX + "smile" , Map .of (COMPATIBLE_WITH_PARAMETER_NAME , VERSION_PATTERN )));
@@ -186,7 +156,7 @@ public XContentType canonical() {
186
156
/**
187
157
* A Versioned YAML based content type.
188
158
*/
189
- VND_YAML (6 ) {
159
+ VND_YAML (6 , YamlXContent . yamlXContent ) {
190
160
@ Override
191
161
public String mediaTypeWithoutParameters () {
192
162
return VENDOR_APPLICATION_PREFIX + "yaml" ;
@@ -197,11 +167,6 @@ public String queryParameter() {
197
167
return "vnd_yaml" ;
198
168
}
199
169
200
- @ Override
201
- public XContent xContent () {
202
- return YamlXContent .yamlXContent ;
203
- }
204
-
205
170
@ Override
206
171
public Set <HeaderValue > headerValues () {
207
172
return Set .of (new HeaderValue (VENDOR_APPLICATION_PREFIX + "yaml" , Map .of (COMPATIBLE_WITH_PARAMETER_NAME , VERSION_PATTERN )));
@@ -215,7 +180,7 @@ public XContentType canonical() {
215
180
/**
216
181
* A Versioned CBOR based content type.
217
182
*/
218
- VND_CBOR (7 ) {
183
+ VND_CBOR (7 , CborXContent . cborXContent ) {
219
184
@ Override
220
185
public String mediaTypeWithoutParameters () {
221
186
return VENDOR_APPLICATION_PREFIX + "cbor" ;
@@ -226,11 +191,6 @@ public String queryParameter() {
226
191
return "vnd_cbor" ;
227
192
}
228
193
229
- @ Override
230
- public XContent xContent () {
231
- return CborXContent .cborXContent ;
232
- }
233
-
234
194
@ Override
235
195
public Set <HeaderValue > headerValues () {
236
196
return Set .of (new HeaderValue (VENDOR_APPLICATION_PREFIX + "cbor" , Map .of (COMPATIBLE_WITH_PARAMETER_NAME , VERSION_PATTERN )));
@@ -275,8 +235,11 @@ public static XContentType fromMediaType(String mediaTypeHeaderValue) throws Ill
275
235
276
236
private final int index ;
277
237
278
- XContentType (int index ) {
238
+ private final XContent xContent ;
239
+
240
+ XContentType (int index , XContent xContent ) {
279
241
this .index = index ;
242
+ this .xContent = xContent ;
280
243
}
281
244
282
245
public static Byte parseVersion (String mediaType ) {
@@ -296,7 +259,9 @@ public String mediaType() {
296
259
return mediaTypeWithoutParameters ();
297
260
}
298
261
299
- public abstract XContent xContent ();
262
+ public final XContent xContent () {
263
+ return xContent ;
264
+ }
300
265
301
266
public abstract String mediaTypeWithoutParameters ();
302
267
0 commit comments