diff --git a/spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java b/spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java index 6803a29341c..e2737744d07 100644 --- a/spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java +++ b/spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 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. @@ -154,7 +154,7 @@ public abstract class LocaleContextHolder { /** * Return the Locale associated with the current thread, if any, - * or the system default Locale else. This is effectively a + * or the system default Locale otherwise. This is effectively a * replacement for {@link java.util.Locale#getDefault()}, * able to optionally respect a user-level Locale setting. *
Note: This method has a fallback to the system default Locale. @@ -219,10 +219,10 @@ public abstract class LocaleContextHolder { /** * Return the TimeZone associated with the current thread, if any, - * or the system default TimeZone else. This is effectively a + * or the system default TimeZone otherwise. This is effectively a * replacement for {@link java.util.TimeZone#getDefault()}, * able to optionally respect a user-level TimeZone setting. - *
Note: This method has a fallback to the system default Locale. + *
Note: This method has a fallback to the system default TimeZone.
* If you'd like to check for the raw LocaleContext content
* (which may indicate no specific time zone through {@code null}, use
* {@link #getLocaleContext()} and call {@link TimeZoneAwareLocaleContext#getTimeZone()}
diff --git a/spring-core/src/main/java/org/springframework/core/Conventions.java b/spring-core/src/main/java/org/springframework/core/Conventions.java
index 86d125248d4..13aec85f4d8 100644
--- a/spring-core/src/main/java/org/springframework/core/Conventions.java
+++ b/spring-core/src/main/java/org/springframework/core/Conventions.java
@@ -281,7 +281,7 @@ public abstract class Conventions {
/**
* Retrieves the {@code Class} of an element in the {@code Collection}.
- * The exact element for which the {@code Class} is retreived will depend
+ * The exact element for which the {@code Class} is retrieved will depend
* on the concrete {@code Collection} implementation.
*/
private static More precisely, this method will return true if objects of sourceType can be
- * converted to the targetType by returning the source object unchanged.
+ * converted to the target type by returning the source object unchanged.
* @param sourceType context about the source type to convert from
* (may be {@code null} if source is {@code null})
* @param targetType context about the target type to convert to (required)
@@ -165,7 +165,7 @@ public class GenericConversionService implements ConfigurableConversionService {
* @since 3.2
*/
public boolean canBypassConvert(TypeDescriptor sourceType, TypeDescriptor targetType) {
- Assert.notNull(targetType, "targetType to convert to cannot be null");
+ Assert.notNull(targetType, "Target type to convert to cannot be null");
if (sourceType == null) {
return true;
}
@@ -176,20 +176,20 @@ public class GenericConversionService implements ConfigurableConversionService {
@Override
@SuppressWarnings("unchecked")
public Returns a NO_OP Converter if the sourceType is assignable to the targetType.
+ * Returns a NO_OP Converter if the source type is assignable to the target type.
* Returns {@code null} otherwise, indicating no suitable converter could be found.
* @param sourceType the source type to convert from
* @param targetType the target type to convert to
diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToOptionalConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToOptionalConverter.java
index 8c701201109..6137012b935 100644
--- a/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToOptionalConverter.java
+++ b/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToOptionalConverter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2015 the original author or authors.
+ * Copyright 2002-2016 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.
@@ -68,13 +68,13 @@ final class ObjectToOptionalConverter implements ConditionalGenericConverter {
else if (source instanceof Optional) {
return source;
}
- else if (targetType.getResolvableType() == null) {
- return Optional.of(source);
- }
- else {
+ else if (targetType.getResolvableType() != null) {
Object target = this.conversionService.convert(source, sourceType, new GenericTypeDescriptor(targetType));
return Optional.ofNullable(target);
}
+ else {
+ return Optional.of(source);
+ }
}
diff --git a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java
index 8dd8243077b..73385a27394 100644
--- a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java
+++ b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2015 the original author or authors.
+ * Copyright 2002-2016 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.
@@ -19,7 +19,6 @@ package org.springframework.util.xml;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.Socket;
-
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.stream.XMLStreamException;
@@ -30,7 +29,6 @@ import javax.xml.transform.stream.StreamResult;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
-
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
@@ -58,11 +56,13 @@ public abstract class AbstractStaxHandlerTestCase {
private XMLReader xmlReader;
+
@Before
public void createXMLReader() throws Exception {
xmlReader = XMLReaderFactory.createXMLReader();
}
+
@Test
public void noNamespacePrefixes() throws Exception {
Assume.assumeTrue(wwwSpringframeworkOrgIsAccessible());
@@ -109,8 +109,7 @@ public abstract class AbstractStaxHandlerTestCase {
@Test
public void noNamespacePrefixesDom() throws Exception {
- DocumentBuilderFactory documentBuilderFactory =
- DocumentBuilderFactory.newInstance();
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
@@ -131,8 +130,7 @@ public abstract class AbstractStaxHandlerTestCase {
@Test
public void namespacePrefixesDom() throws Exception {
- DocumentBuilderFactory documentBuilderFactory =
- DocumentBuilderFactory.newInstance();
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java
index d2c44d66b68..2ad1ae9a43d 100644
--- a/spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java
+++ b/spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2016 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.
@@ -27,8 +27,7 @@ import javax.xml.transform.Result;
public class StaxEventHandlerTests extends AbstractStaxHandlerTestCase {
@Override
- protected AbstractStaxHandler createStaxHandler(Result result)
- throws XMLStreamException {
+ protected AbstractStaxHandler createStaxHandler(Result result) throws XMLStreamException {
XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(result);
return new StaxEventHandler(eventWriter);
diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java
index a039826bed0..116aec625e7 100644
--- a/spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java
+++ b/spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2016 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.
@@ -27,8 +27,7 @@ import javax.xml.transform.Result;
public class StaxStreamHandlerTests extends AbstractStaxHandlerTestCase {
@Override
- protected AbstractStaxHandler createStaxHandler(Result result)
- throws XMLStreamException {
+ protected AbstractStaxHandler createStaxHandler(Result result) throws XMLStreamException {
XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(result);
return new StaxStreamHandler(streamWriter);
diff --git a/spring-oxm/src/main/java/org/springframework/oxm/Marshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/Marshaller.java
index 9dfb7214d20..2fe594f2e89 100644
--- a/spring-oxm/src/main/java/org/springframework/oxm/Marshaller.java
+++ b/spring-oxm/src/main/java/org/springframework/oxm/Marshaller.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2016 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.
@@ -35,7 +35,7 @@ import javax.xml.transform.Result;
public interface Marshaller {
/**
- * Indicates whether this marshaller can marshal instances of the supplied type.
+ * Indicate whether this marshaller can marshal instances of the supplied type.
* @param clazz the class that this marshaller is being asked if it can marshal
* @return {@code true} if this marshaller can indeed marshal instances of the supplied class;
* {@code false} otherwise
@@ -43,7 +43,7 @@ public interface Marshaller {
boolean supports(Class> clazz);
/**
- * Marshals the object graph with the given root into the provided {@link Result}.
+ * Marshal the object graph with the given root into the provided {@link Result}.
* @param graph the root of the object graph to marshal
* @param result the result to marshal to
* @throws IOException if an I/O error occurs
diff --git a/spring-oxm/src/main/java/org/springframework/oxm/Unmarshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/Unmarshaller.java
index e5fbb959adc..400cc9bc5df 100644
--- a/spring-oxm/src/main/java/org/springframework/oxm/Unmarshaller.java
+++ b/spring-oxm/src/main/java/org/springframework/oxm/Unmarshaller.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2016 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.
@@ -30,7 +30,7 @@ import javax.xml.transform.Source;
public interface Unmarshaller {
/**
- * Indicates whether this unmarshaller can unmarshal instances of the supplied type.
+ * Indicate whether this unmarshaller can unmarshal instances of the supplied type.
* @param clazz the class that this unmarshaller is being asked if it can marshal
* @return {@code true} if this unmarshaller can indeed unmarshal to the supplied class;
* {@code false} otherwise
@@ -38,7 +38,7 @@ public interface Unmarshaller {
boolean supports(Class> clazz);
/**
- * Unmarshals the given {@link Source} into an object graph.
+ * Unmarshal the given {@link Source} into an object graph.
* @param source the source to marshal from
* @return the object graph
* @throws IOException if an I/O error occurs
diff --git a/spring-web/src/main/java/org/springframework/web/client/AsyncRestOperations.java b/spring-web/src/main/java/org/springframework/web/client/AsyncRestOperations.java
index 0c4420366e2..19658f6bb63 100644
--- a/spring-web/src/main/java/org/springframework/web/client/AsyncRestOperations.java
+++ b/spring-web/src/main/java/org/springframework/web/client/AsyncRestOperations.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2016 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.
@@ -29,12 +29,14 @@ import org.springframework.http.ResponseEntity;
import org.springframework.util.concurrent.ListenableFuture;
/**
- * Interface specifying a basic set of asynchronous RESTful operations. Implemented by
- * {@link AsyncRestTemplate}. Not often used directly, but a useful option to enhance
- * testability, as it can easily be mocked or stubbed.
+ * Interface specifying a basic set of asynchronous RESTful operations.
+ * Implemented by {@link AsyncRestTemplate}. Not often used directly, but a useful
+ * option to enhance testability, as it can easily be mocked or stubbed.
*
* @author Arjen Poutsma
* @since 4.0
+ * @see AsyncRestTemplate
+ * @see RestOperations
*/
public interface AsyncRestOperations {
@@ -47,8 +49,8 @@ public interface AsyncRestOperations {
// GET
/**
- * Asynchronously retrieve an entity by doing a GET on the specified URL. The response is
- * converted and stored in an {@link ResponseEntity}.
+ * Asynchronously retrieve an entity by doing a GET on the specified URL.
+ * The response is converted and stored in an {@link ResponseEntity}.
* URI Template variables are expanded using the given URI variables, if any.
* @param url the URL
* @param responseType the type of the return value
@@ -59,8 +61,8 @@ public interface AsyncRestOperations {
Object... uriVariables) throws RestClientException;
/**
- * Asynchronously retrieve a representation by doing a GET on the URI template. The
- * response is converted and stored in an {@link ResponseEntity}.
+ * Asynchronously retrieve a representation by doing a GET on the URI template.
+ * The response is converted and stored in an {@link ResponseEntity}.
* URI Template variables are expanded using the given map.
* @param url the URL
* @param responseType the type of the return value
@@ -80,6 +82,7 @@ public interface AsyncRestOperations {
URI Template variables are expanded using the given URI variables, if any.
* @param url the URL
- * @param request the Object to be POSTed, may be {@code null}
+ * @param request the Object to be POSTed (may be {@code null})
* @param uriVariables the variables to expand the template
* @return the value for the {@code Location} header wrapped in a {@link Future}
* @see org.springframework.http.HttpEntity
@@ -131,7 +135,7 @@ public interface AsyncRestOperations {
* typically indicates where the new resource is stored.
* URI Template variables are expanded using the given map.
* @param url the URL
- * @param request the Object to be POSTed, may be {@code null}
+ * @param request the Object to be POSTed (may be {@code null})
* @param uriVariables the variables to expand the template
* @return the value for the {@code Location} header wrapped in a {@link Future}
* @see org.springframework.http.HttpEntity
@@ -144,7 +148,7 @@ public interface AsyncRestOperations {
* returns the value of the {@code Location} header. This header typically indicates
* where the new resource is stored.
* @param url the URL
- * @param request the Object to be POSTed, may be {@code null}
+ * @param request the Object to be POSTed (may be {@code null})
* @return the value for the {@code Location} header wrapped in a {@link Future}
* @see org.springframework.http.HttpEntity
*/
@@ -155,7 +159,7 @@ public interface AsyncRestOperations {
* and asynchronously returns the response as {@link ResponseEntity}.
* URI Template variables are expanded using the given URI variables, if any.
* @param url the URL
- * @param request the Object to be POSTed, may be {@code null}
+ * @param request the Object to be POSTed (may be {@code null})
* @param uriVariables the variables to expand the template
* @return the entity wrapped in a {@link Future}
* @see org.springframework.http.HttpEntity
@@ -168,26 +172,26 @@ public interface AsyncRestOperations {
* and asynchronously returns the response as {@link ResponseEntity}.
* URI Template variables are expanded using the given map.
* @param url the URL
- * @param request the Object to be POSTed, may be {@code null}
+ * @param request the Object to be POSTed (may be {@code null})
* @param uriVariables the variables to expand the template
* @return the entity wrapped in a {@link Future}
* @see org.springframework.http.HttpEntity
*/
URI Template variables are expanded using the given URI variables, if any.
* The Future will return a {@code null} result upon completion.
* @param url the URL
- * @param request the Object to be PUT, may be {@code null}
+ * @param request the Object to be PUT (may be {@code null})
* @param uriVariables the variables to expand the template
* @see HttpEntity
*/
@@ -207,7 +211,7 @@ public interface AsyncRestOperations {
* URI Template variables are expanded using the given map.
* The Future will return a {@code null} result upon completion.
* @param url the URL
- * @param request the Object to be PUT, may be {@code null}
+ * @param request the Object to be PUT (may be {@code null})
* @param uriVariables the variables to expand the template
* @see HttpEntity
*/
@@ -218,11 +222,12 @@ public interface AsyncRestOperations {
* Creates a new resource by PUTting the given object to URL.
* The Future will return a {@code null} result upon completion.
* @param url the URL
- * @param request the Object to be PUT, may be {@code null}
+ * @param request the Object to be PUT (may be {@code null})
* @see HttpEntity
*/
ListenableFuture> put(URI url, HttpEntity> request) throws RestClientException;
+
// DELETE
/**
@@ -251,6 +256,7 @@ public interface AsyncRestOperations {
*/
ListenableFuture> delete(URI url) throws RestClientException;
+
// OPTIONS
/**
@@ -344,7 +350,7 @@ public interface AsyncRestOperations {
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
* @param requestEntity the entity (headers and/or body) to write to the
- * request, may be {@code null}
+ * request (may be {@code null})
* @param responseType the type of the return value
* @param uriVariables the variables to expand in the template
* @return the response as entity wrapped in a {@link Future}
@@ -364,7 +370,8 @@ public interface AsyncRestOperations {
*
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
- * @param requestEntity the entity (headers and/or body) to write to the request, may be {@code null}
+ * @param requestEntity the entity (headers and/or body) to write to the request
+ * (may be {@code null})
* @param responseType the type of the return value
* @param uriVariables the variables to expand in the template
* @return the response as entity wrapped in a {@link Future}
@@ -384,7 +391,8 @@ public interface AsyncRestOperations {
*
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
- * @param requestEntity the entity (headers and/or body) to write to the request, may be {@code null}
+ * @param requestEntity the entity (headers and/or body) to write to the request
+ * (may be {@code null})
* @param responseType the type of the return value
* @return the response as entity wrapped in a {@link Future}
*/
diff --git a/spring-web/src/main/java/org/springframework/web/client/AsyncRestTemplate.java b/spring-web/src/main/java/org/springframework/web/client/AsyncRestTemplate.java
index 4a4a5a57f3e..396da2ae847 100644
--- a/spring-web/src/main/java/org/springframework/web/client/AsyncRestTemplate.java
+++ b/spring-web/src/main/java/org/springframework/web/client/AsyncRestTemplate.java
@@ -58,10 +58,8 @@ import org.springframework.web.util.UriTemplateHandler;
* wrappers as opposed to concrete results.
*
* The {@code AsyncRestTemplate} exposes a synchronous {@link RestTemplate} via the
- * {@link #getRestOperations()} method, and it shares its
- * {@linkplain #setErrorHandler(ResponseErrorHandler) error handler} and
- * {@linkplain #setMessageConverters(List) message converters} with this
- * {@code RestTemplate}.
+ * {@link #getRestOperations()} method and shares its {@linkplain #setErrorHandler error handler}
+ * and {@linkplain #setMessageConverters message converters} with that {@code RestTemplate}.
*
* Note: by default {@code AsyncRestTemplate} relies on
* standard JDK facilities to establish HTTP connections. You can switch to use
diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java b/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java
index 9eb31c0d361..ce9910ec180 100644
--- a/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java
+++ b/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java
@@ -179,44 +179,6 @@ public final class ModelFactory {
return result;
}
- /**
- * Derives the model attribute name for a method parameter based on:
- * Also see {@link RequestResponseBodyMethodProcessorMockTests}.
+ * actual delegation to {@link HttpMessageConverter} instances. Also see
+ * {@link RequestResponseBodyMethodProcessorMockTests}.
*
* @author Rossen Stoyanchev
* @author Sebastien Deleuze
- *
- * @return the derived name; never {@code null} or an empty string
- */
- public static String getNameForParameter(MethodParameter parameter) {
- ModelAttribute ann = parameter.getParameterAnnotation(ModelAttribute.class);
- String name = (ann != null ? ann.value() : null);
- return StringUtils.hasText(name) ? name : Conventions.getVariableNameForParameter(parameter);
- }
-
- /**
- * Derive the model attribute name for the given return value using one of:
- *
- *
- * @param returnValue the value returned from a method invocation
- * @param returnType the return type of the method
- * @return the model name, never {@code null} nor empty
- */
- public static String getNameForReturnValue(Object returnValue, MethodParameter returnType) {
- ModelAttribute ann = returnType.getMethodAnnotation(ModelAttribute.class);
- if (ann != null && StringUtils.hasText(ann.value())) {
- return ann.value();
- }
- else {
- Method method = returnType.getMethod();
- Class> containingClass = returnType.getContainingClass();
- Class> resolvedType = GenericTypeResolver.resolveReturnType(method, containingClass);
- return Conventions.getVariableNameForReturnType(method, resolvedType, returnValue);
- }
- }
-
/**
* Promote model attributes listed as {@code @SessionAttributes} to the session.
* Add {@link BindingResult} attributes where necessary.
@@ -244,10 +206,8 @@ public final class ModelFactory {
List
+ *
+ * @param parameter a descriptor for the method parameter
+ * @return the derived name (never {@code null} or empty String)
+ */
+ public static String getNameForParameter(MethodParameter parameter) {
+ ModelAttribute ann = parameter.getParameterAnnotation(ModelAttribute.class);
+ String name = (ann != null ? ann.value() : null);
+ return (StringUtils.hasText(name) ? name : Conventions.getVariableNameForParameter(parameter));
+ }
+
+ /**
+ * Derive the model attribute name for the given return value based on:
+ *
+ *
+ * @param returnValue the value returned from a method invocation
+ * @param returnType a descriptor for the return type of the method
+ * @return the derived name (never {@code null} or empty String)
+ */
+ public static String getNameForReturnValue(Object returnValue, MethodParameter returnType) {
+ ModelAttribute ann = returnType.getMethodAnnotation(ModelAttribute.class);
+ if (ann != null && StringUtils.hasText(ann.value())) {
+ return ann.value();
+ }
+ else {
+ Method method = returnType.getMethod();
+ Class> containingClass = returnType.getContainingClass();
+ Class> resolvedType = GenericTypeResolver.resolveReturnType(method, containingClass);
+ return Conventions.getVariableNameForReturnType(method, resolvedType, returnValue);
+ }
+ }
+
+
private static class ModelMethod {
private final InvocableHandlerMethod handlerMethod;
private final Set