Add constants for application/cbor to MediaType
Closes gh-23042
This commit is contained in:
@@ -73,6 +73,18 @@ public class MediaType extends MimeType implements Serializable {
|
||||
*/
|
||||
public static final String APPLICATION_ATOM_XML_VALUE = "application/atom+xml";
|
||||
|
||||
/**
|
||||
* Public constant media type for {@code application/cbor}.
|
||||
* @since 5.2
|
||||
*/
|
||||
public static final MediaType APPLICATION_CBOR;
|
||||
|
||||
/**
|
||||
* A String equivalent of {@link MediaType#APPLICATION_CBOR}.
|
||||
* @since 5.2
|
||||
*/
|
||||
public static final String APPLICATION_CBOR_VALUE = "application/cbor";
|
||||
|
||||
/**
|
||||
* Public constant media type for {@code application/x-www-form-urlencoded}.
|
||||
*/
|
||||
@@ -338,6 +350,7 @@ public class MediaType extends MimeType implements Serializable {
|
||||
// Not using "valueOf' to avoid static init cost
|
||||
ALL = new MediaType("*", "*");
|
||||
APPLICATION_ATOM_XML = new MediaType("application", "atom+xml");
|
||||
APPLICATION_CBOR = new MediaType("application", "cbor");
|
||||
APPLICATION_FORM_URLENCODED = new MediaType("application", "x-www-form-urlencoded");
|
||||
APPLICATION_JSON = new MediaType("application", "json");
|
||||
APPLICATION_JSON_UTF8 = new MediaType("application", "json", StandardCharsets.UTF_8);
|
||||
|
||||
@@ -43,7 +43,7 @@ import org.springframework.util.MimeType;
|
||||
public class Jackson2CborDecoder extends AbstractJackson2Decoder {
|
||||
|
||||
public Jackson2CborDecoder() {
|
||||
this(Jackson2ObjectMapperBuilder.cbor().build(), new MediaType("application", "cbor"));
|
||||
this(Jackson2ObjectMapperBuilder.cbor().build(), MediaType.APPLICATION_CBOR);
|
||||
}
|
||||
|
||||
public Jackson2CborDecoder(ObjectMapper mapper, MimeType... mimeTypes) {
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.springframework.util.MimeType;
|
||||
public class Jackson2CborEncoder extends AbstractJackson2Encoder {
|
||||
|
||||
public Jackson2CborEncoder() {
|
||||
this(Jackson2ObjectMapperBuilder.cbor().build(), new MediaType("application", "cbor"));
|
||||
this(Jackson2ObjectMapperBuilder.cbor().build(), MediaType.APPLICATION_CBOR);
|
||||
}
|
||||
|
||||
public Jackson2CborEncoder(ObjectMapper mapper, MimeType... mimeTypes) {
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.util.Assert;
|
||||
* <a href="https://github.com/FasterXML/jackson-dataformats-binary/tree/master/cbor">
|
||||
* the dedicated Jackson 2.x extension</a>.
|
||||
*
|
||||
* <p>By default, this converter supports {@code "application/cbor"} media type. This can be
|
||||
* <p>By default, this converter supports {@value MediaType#APPLICATION_CBOR_VALUE} media type. This can be
|
||||
* overridden by setting the {@link #setSupportedMediaTypes supportedMediaTypes} property.
|
||||
*
|
||||
* <p>The default constructor uses the default configuration provided by {@link Jackson2ObjectMapperBuilder}.
|
||||
@@ -57,7 +57,7 @@ public class MappingJackson2CborHttpMessageConverter extends AbstractJackson2Htt
|
||||
* @see Jackson2ObjectMapperBuilder#cbor()
|
||||
*/
|
||||
public MappingJackson2CborHttpMessageConverter(ObjectMapper objectMapper) {
|
||||
super(objectMapper, new MediaType("application", "cbor"));
|
||||
super(objectMapper, MediaType.APPLICATION_CBOR);
|
||||
Assert.isInstanceOf(CBORFactory.class, objectMapper.getFactory(), "CBORFactory required");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user