diff --git a/spring-core/src/main/java/org/springframework/core/ParameterizedTypeReference.java b/spring-core/src/main/java/org/springframework/core/ParameterizedTypeReference.java index 2de7a9d38f..5ed2e1ad6e 100644 --- a/spring-core/src/main/java/org/springframework/core/ParameterizedTypeReference.java +++ b/spring-core/src/main/java/org/springframework/core/ParameterizedTypeReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,14 +24,14 @@ import org.springframework.util.Assert; /** * The purpose of this class is to enable capturing and passing a generic * {@link Type}. In order to capture the generic type and retain it at runtime, - * you need to create a subclass as follows: + * you need to create a subclass (ideally as anonymous inline class) as follows: * *
  * ParameterizedTypeReference<List<String>> typeRef = new ParameterizedTypeReference<List<String>>() {};
  * 
* - *

The resulting {@code typeReference} instance can then be used to obtain a - * {@link Type} instance that carries parameterized type information. + *

The resulting {@code typeRef} instance can then be used to obtain a {@link Type} + * instance that carries the captured parameterized type information at runtime. * For more information on "super type tokens" see the link to Neal Gafter's blog post. * * @author Arjen Poutsma diff --git a/spring-core/src/main/java/org/springframework/util/xml/TransformerUtils.java b/spring-core/src/main/java/org/springframework/util/xml/TransformerUtils.java index a7aa7bcb19..42d881490b 100644 --- a/spring-core/src/main/java/org/springframework/util/xml/TransformerUtils.java +++ b/spring-core/src/main/java/org/springframework/util/xml/TransformerUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,8 @@ import javax.xml.transform.Transformer; import org.springframework.util.Assert; /** - * Contains common behavior relating to {@link javax.xml.transform.Transformer Transformers}, and the - * {@code javax.xml.transform} package in general. + * Contains common behavior relating to {@link javax.xml.transform.Transformer Transformers} + * and the {@code javax.xml.transform} package in general. * * @author Rick Evans * @author Juergen Hoeller @@ -32,16 +32,16 @@ import org.springframework.util.Assert; public abstract class TransformerUtils { /** - * The indent amount of characters if {@link #enableIndenting(javax.xml.transform.Transformer) indenting is enabled}. + * The indent amount of characters if {@link #enableIndenting indenting is enabled}. *

Defaults to "2". */ public static final int DEFAULT_INDENT_AMOUNT = 2; + /** - * Enable indenting for the supplied {@link javax.xml.transform.Transformer}.

If the underlying XSLT engine is - * Xalan, then the special output key {@code indent-amount} will be also be set to a value of {@link - * #DEFAULT_INDENT_AMOUNT} characters. - * + * Enable indenting for the supplied {@link javax.xml.transform.Transformer}. + *

If the underlying XSLT engine is Xalan, then the special output key {@code indent-amount} + * will be also be set to a value of {@link #DEFAULT_INDENT_AMOUNT} characters. * @param transformer the target transformer * @see javax.xml.transform.Transformer#setOutputProperty(String, String) * @see javax.xml.transform.OutputKeys#INDENT @@ -51,18 +51,19 @@ public abstract class TransformerUtils { } /** - * Enable indenting for the supplied {@link javax.xml.transform.Transformer}.

If the underlying XSLT engine is - * Xalan, then the special output key {@code indent-amount} will be also be set to a value of {@link - * #DEFAULT_INDENT_AMOUNT} characters. - * - * @param transformer the target transformer - * @param indentAmount the size of the indent (2 characters, 3 characters, etc.) + * Enable indenting for the supplied {@link javax.xml.transform.Transformer}. + *

If the underlying XSLT engine is Xalan, then the special output key {@code indent-amount} + * will be also be set to a value of {@link #DEFAULT_INDENT_AMOUNT} characters. + * @param transformer the target transformer + * @param indentAmount the size of the indent (2 characters, 3 characters, etc) * @see javax.xml.transform.Transformer#setOutputProperty(String, String) * @see javax.xml.transform.OutputKeys#INDENT */ public static void enableIndenting(Transformer transformer, int indentAmount) { Assert.notNull(transformer, "Transformer must not be null"); - Assert.isTrue(indentAmount > -1, () -> "The indent amount cannot be less than zero : got " + indentAmount); + if (indentAmount < 0) { + throw new IllegalArgumentException("Invalid indent amount (must not be less than zero): " + indentAmount); + } transformer.setOutputProperty(OutputKeys.INDENT, "yes"); try { // Xalan-specific, but this is the most common XSLT engine in any case @@ -74,7 +75,6 @@ public abstract class TransformerUtils { /** * Disable indenting for the supplied {@link javax.xml.transform.Transformer}. - * * @param transformer the target transformer * @see javax.xml.transform.OutputKeys#INDENT */ diff --git a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java index 30475ec603..d83a9d51c5 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java @@ -580,8 +580,7 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true); for (int i = 0; i < resources.length; i++) { Resource resource = resources[i]; - Assert.notNull(resource, "Resource is null"); - Assert.isTrue(resource.exists(), () -> "Resource " + resource + " does not exist"); + Assert.isTrue(resource != null && resource.exists(), () -> "Resource does not exist: " + resource); InputSource inputSource = SaxResourceUtils.createInputSource(resource); schemaSources[i] = new SAXSource(xmlReader, inputSource); } @@ -595,8 +594,8 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi @Override public boolean supports(Class clazz) { - return ((this.supportJaxbElementClass && JAXBElement.class.isAssignableFrom(clazz)) || - supportsInternal(clazz, this.checkForXmlRootElement)); + return (this.supportJaxbElementClass && JAXBElement.class.isAssignableFrom(clazz)) || + supportsInternal(clazz, this.checkForXmlRootElement); } @Override diff --git a/spring-web/src/main/java/org/springframework/web/util/HtmlCharacterEntityReferences.java b/spring-web/src/main/java/org/springframework/web/util/HtmlCharacterEntityReferences.java index f8cf084504..4d00262dc3 100644 --- a/spring-web/src/main/java/org/springframework/web/util/HtmlCharacterEntityReferences.java +++ b/spring-web/src/main/java/org/springframework/web/util/HtmlCharacterEntityReferences.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -120,7 +120,7 @@ class HtmlCharacterEntityReferences { } /** - * Return the reference mapped to the given character or {@code null}. + * Return the reference mapped to the given character, or {@code null} if none found. */ @Nullable public String convertToReference(char character) { @@ -128,7 +128,7 @@ class HtmlCharacterEntityReferences { } /** - * Return the reference mapped to the given character or {@code null}. + * Return the reference mapped to the given character, or {@code null} if none found. * @since 4.1.2 */ @Nullable