From 27fdf56ed5c2ecdfdf3f718caae47b2251954aef Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Fri, 10 Feb 2023 09:36:54 +0000 Subject: [PATCH] Polishing contribution Closes gh-29949 --- .../json/ProblemDetailJacksonXmlMixin.java | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/ProblemDetailJacksonXmlMixin.java b/spring-web/src/main/java/org/springframework/http/converter/json/ProblemDetailJacksonXmlMixin.java index eb7fefdb2a7..f3a14a58132 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/ProblemDetailJacksonXmlMixin.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/ProblemDetailJacksonXmlMixin.java @@ -30,46 +30,48 @@ import org.springframework.lang.Nullable; import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY; /** - * Intended to be identical to {@link ProblemDetailJacksonMixin} but for used - * instead of it when jackson-dataformat-xml is on the classpath. Customizes the - * XML root element name and adds namespace information. + * Provides the same declarations as {@link ProblemDetailJacksonMixin}, and + * some additional ones to support XML serialization when + * jackson-dataformat-xml is on the classpath. Customizes the XML root element + * name and adds namespace information. * - *

Note: Unfortunately, we cannot just use {@code JsonRootName} to specify - * the namespace since that is not inherited by fields of the class. This is - * why we need a dedicated mixin for use when jackson-dataformat-xml is on the - * classpath. For more details, see + *

Note that we can't use {@code JsonRootName} to specify the namespace + * since that is not inherited by fields of the class. This is why we need a + * dedicated mixin for use when jackson-dataformat-xml is on the classpath. + * For more details, see * FasterXML/jackson-dataformat-xml#355. * * @author Rossen Stoyanchev - * @author Yanming Zhou * @since 6.0.5 */ @JsonInclude(NON_EMPTY) -@JacksonXmlRootElement(localName = "problem", namespace = ProblemDetailJacksonXmlMixin.NAMESPACE) +@JacksonXmlRootElement(localName = "problem", namespace = ProblemDetailJacksonXmlMixin.RFC_7807_NAMESPACE) public interface ProblemDetailJacksonXmlMixin { - String NAMESPACE = "urn:ietf:rfc:7807"; + /** RFC 7807 namespace. */ + String RFC_7807_NAMESPACE = "urn:ietf:rfc:7807"; - @JacksonXmlProperty(namespace = NAMESPACE) + + @JacksonXmlProperty(namespace = RFC_7807_NAMESPACE) URI getType(); - @JacksonXmlProperty(namespace = NAMESPACE) + @JacksonXmlProperty(namespace = RFC_7807_NAMESPACE) String getTitle(); - @JacksonXmlProperty(namespace = NAMESPACE) + @JacksonXmlProperty(namespace = RFC_7807_NAMESPACE) int getStatus(); - @JacksonXmlProperty(namespace = NAMESPACE) + @JacksonXmlProperty(namespace = RFC_7807_NAMESPACE) String getDetail(); - @JacksonXmlProperty(namespace = NAMESPACE) + @JacksonXmlProperty(namespace = RFC_7807_NAMESPACE) URI getInstance(); @JsonAnySetter void setProperty(String name, @Nullable Object value); @JsonAnyGetter - @JacksonXmlProperty(namespace = NAMESPACE) + @JacksonXmlProperty(namespace = RFC_7807_NAMESPACE) Map getProperties(); }