Skip to content

Commit b592dd7

Browse files
committed
Polishing
(cherry picked from commit b5f2e56)
1 parent 86614af commit b592dd7

File tree

16 files changed

+130
-132
lines changed

16 files changed

+130
-132
lines changed

spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -154,7 +154,7 @@ else if (locale != null) {
154154

155155
/**
156156
* Return the Locale associated with the current thread, if any,
157-
* or the system default Locale else. This is effectively a
157+
* or the system default Locale otherwise. This is effectively a
158158
* replacement for {@link java.util.Locale#getDefault()},
159159
* able to optionally respect a user-level Locale setting.
160160
* <p>Note: This method has a fallback to the system default Locale.
@@ -219,10 +219,10 @@ else if (locale != null) {
219219

220220
/**
221221
* Return the TimeZone associated with the current thread, if any,
222-
* or the system default TimeZone else. This is effectively a
222+
* or the system default TimeZone otherwise. This is effectively a
223223
* replacement for {@link java.util.TimeZone#getDefault()},
224224
* able to optionally respect a user-level TimeZone setting.
225-
* <p>Note: This method has a fallback to the system default Locale.
225+
* <p>Note: This method has a fallback to the system default TimeZone.
226226
* If you'd like to check for the raw LocaleContext content
227227
* (which may indicate no specific time zone through {@code null}, use
228228
* {@link #getLocaleContext()} and call {@link TimeZoneAwareLocaleContext#getTimeZone()}

spring-core/src/main/java/org/springframework/core/Conventions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ private static String pluralize(String name) {
281281

282282
/**
283283
* Retrieves the {@code Class} of an element in the {@code Collection}.
284-
* The exact element for which the {@code Class} is retreived will depend
284+
* The exact element for which the {@code Class} is retrieved will depend
285285
* on the concrete {@code Collection} implementation.
286286
*/
287287
private static <E> E peekAhead(Collection<E> collection) {

spring-core/src/main/java/org/springframework/core/convert/support/CollectionToStringConverter.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,18 +36,21 @@ final class CollectionToStringConverter implements ConditionalGenericConverter {
3636

3737
private final ConversionService conversionService;
3838

39+
3940
public CollectionToStringConverter(ConversionService conversionService) {
4041
this.conversionService = conversionService;
4142
}
4243

44+
4345
@Override
4446
public Set<ConvertiblePair> getConvertibleTypes() {
4547
return Collections.singleton(new ConvertiblePair(Collection.class, String.class));
4648
}
4749

4850
@Override
4951
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
50-
return ConversionUtils.canConvertElements(sourceType.getElementTypeDescriptor(), targetType, this.conversionService);
52+
return ConversionUtils.canConvertElements(
53+
sourceType.getElementTypeDescriptor(), targetType, this.conversionService);
5154
}
5255

5356
@Override
@@ -56,7 +59,7 @@ public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor t
5659
return null;
5760
}
5861
Collection<?> sourceCollection = (Collection<?>) source;
59-
if (sourceCollection.size() == 0) {
62+
if (sourceCollection.isEmpty()) {
6063
return "";
6164
}
6265
StringBuilder sb = new StringBuilder();
@@ -65,7 +68,8 @@ public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor t
6568
if (i > 0) {
6669
sb.append(DELIMITER);
6770
}
68-
Object targetElement = this.conversionService.convert(sourceElement, sourceType.elementTypeDescriptor(sourceElement), targetType);
71+
Object targetElement = this.conversionService.convert(
72+
sourceElement, sourceType.elementTypeDescriptor(sourceElement), targetType);
6973
sb.append(targetElement);
7074
i++;
7175
}

spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,14 @@ public void removeConvertible(Class<?> sourceType, Class<?> targetType) {
138138

139139
@Override
140140
public boolean canConvert(Class<?> sourceType, Class<?> targetType) {
141-
Assert.notNull(targetType, "targetType to convert to cannot be null");
141+
Assert.notNull(targetType, "Target type to convert to cannot be null");
142142
return canConvert((sourceType != null ? TypeDescriptor.valueOf(sourceType) : null),
143143
TypeDescriptor.valueOf(targetType));
144144
}
145145

146146
@Override
147147
public boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType) {
148-
Assert.notNull(targetType, "targetType to convert to cannot be null");
148+
Assert.notNull(targetType, "Target type to convert to cannot be null");
149149
if (sourceType == null) {
150150
return true;
151151
}
@@ -154,9 +154,9 @@ public boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType)
154154
}
155155

156156
/**
157-
* Return whether conversion between the sourceType and targetType can be bypassed.
157+
* Return whether conversion between the source type and the target type can be bypassed.
158158
* <p>More precisely, this method will return true if objects of sourceType can be
159-
* converted to the targetType by returning the source object unchanged.
159+
* converted to the target type by returning the source object unchanged.
160160
* @param sourceType context about the source type to convert from
161161
* (may be {@code null} if source is {@code null})
162162
* @param targetType context about the target type to convert to (required)
@@ -165,7 +165,7 @@ public boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType)
165165
* @since 3.2
166166
*/
167167
public boolean canBypassConvert(TypeDescriptor sourceType, TypeDescriptor targetType) {
168-
Assert.notNull(targetType, "targetType to convert to cannot be null");
168+
Assert.notNull(targetType, "Target type to convert to cannot be null");
169169
if (sourceType == null) {
170170
return true;
171171
}
@@ -176,20 +176,20 @@ public boolean canBypassConvert(TypeDescriptor sourceType, TypeDescriptor target
176176
@Override
177177
@SuppressWarnings("unchecked")
178178
public <T> T convert(Object source, Class<T> targetType) {
179-
Assert.notNull(targetType, "targetType to convert to cannot be null");
179+
Assert.notNull(targetType, "Target type to convert to cannot be null");
180180
return (T) convert(source, TypeDescriptor.forObject(source), TypeDescriptor.valueOf(targetType));
181181
}
182182

183183
@Override
184184
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
185-
Assert.notNull(targetType, "targetType to convert to cannot be null");
185+
Assert.notNull(targetType, "Target type to convert to cannot be null");
186186
if (sourceType == null) {
187-
Assert.isTrue(source == null, "source must be [null] if sourceType == [null]");
187+
Assert.isTrue(source == null, "Source must be [null] if source type == [null]");
188188
return handleResult(null, targetType, convertNullSource(null, targetType));
189189
}
190190
if (source != null && !sourceType.getObjectType().isInstance(source)) {
191-
throw new IllegalArgumentException("source to convert from must be an instance of " +
192-
sourceType + "; instead it was a " + source.getClass().getName());
191+
throw new IllegalArgumentException("Source to convert from must be an instance of [" +
192+
sourceType + "]; instead it was a [" + source.getClass().getName() + "]");
193193
}
194194
GenericConverter converter = getConverter(sourceType, targetType);
195195
if (converter != null) {
@@ -201,9 +201,9 @@ public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor t
201201

202202
/**
203203
* Convenience operation for converting a source object to the specified targetType,
204-
* where the targetType is a descriptor that provides additional conversion context.
204+
* where the target type is a descriptor that provides additional conversion context.
205205
* Simply delegates to {@link #convert(Object, TypeDescriptor, TypeDescriptor)} and
206-
* encapsulates the construction of the sourceType descriptor using
206+
* encapsulates the construction of the source type descriptor using
207207
* {@link TypeDescriptor#forObject(Object)}.
208208
* @param source the source object
209209
* @param targetType the target type
@@ -230,8 +230,8 @@ public String toString() {
230230
* {@link java.util.Optional#empty()} instance if the target type is
231231
* {@code java.util.Optional}. Subclasses may override this to return
232232
* custom {@code null} objects for specific target types.
233-
* @param sourceType the sourceType to convert from
234-
* @param targetType the targetType to convert to
233+
* @param sourceType the source type to convert from
234+
* @param targetType the target type to convert to
235235
* @return the converted null object
236236
*/
237237
protected Object convertNullSource(TypeDescriptor sourceType, TypeDescriptor targetType) {
@@ -275,7 +275,7 @@ protected GenericConverter getConverter(TypeDescriptor sourceType, TypeDescripto
275275

276276
/**
277277
* Return the default converter if no converter is found for the given sourceType/targetType pair.
278-
* <p>Returns a NO_OP Converter if the sourceType is assignable to the targetType.
278+
* <p>Returns a NO_OP Converter if the source type is assignable to the target type.
279279
* Returns {@code null} otherwise, indicating no suitable converter could be found.
280280
* @param sourceType the source type to convert from
281281
* @param targetType the target type to convert to

spring-core/src/main/java/org/springframework/core/convert/support/ObjectToOptionalConverter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -68,13 +68,13 @@ public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor t
6868
else if (source instanceof Optional) {
6969
return source;
7070
}
71-
else if (targetType.getResolvableType() == null) {
72-
return Optional.of(source);
73-
}
74-
else {
71+
else if (targetType.getResolvableType() != null) {
7572
Object target = this.conversionService.convert(source, sourceType, new GenericTypeDescriptor(targetType));
7673
return Optional.ofNullable(target);
7774
}
75+
else {
76+
return Optional.of(source);
77+
}
7878
}
7979

8080

spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@
1919
import java.io.StringReader;
2020
import java.io.StringWriter;
2121
import java.net.Socket;
22-
2322
import javax.xml.parsers.DocumentBuilder;
2423
import javax.xml.parsers.DocumentBuilderFactory;
2524
import javax.xml.stream.XMLStreamException;
@@ -30,7 +29,6 @@
3029
import org.junit.Assume;
3130
import org.junit.Before;
3231
import org.junit.Test;
33-
3432
import org.w3c.dom.Document;
3533
import org.xml.sax.InputSource;
3634
import org.xml.sax.XMLReader;
@@ -58,11 +56,13 @@ public abstract class AbstractStaxHandlerTestCase {
5856

5957
private XMLReader xmlReader;
6058

59+
6160
@Before
6261
public void createXMLReader() throws Exception {
6362
xmlReader = XMLReaderFactory.createXMLReader();
6463
}
6564

65+
6666
@Test
6767
public void noNamespacePrefixes() throws Exception {
6868
Assume.assumeTrue(wwwSpringframeworkOrgIsAccessible());
@@ -109,8 +109,7 @@ public void namespacePrefixes() throws Exception {
109109

110110
@Test
111111
public void noNamespacePrefixesDom() throws Exception {
112-
DocumentBuilderFactory documentBuilderFactory =
113-
DocumentBuilderFactory.newInstance();
112+
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
114113
documentBuilderFactory.setNamespaceAware(true);
115114
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
116115

@@ -131,8 +130,7 @@ public void noNamespacePrefixesDom() throws Exception {
131130

132131
@Test
133132
public void namespacePrefixesDom() throws Exception {
134-
DocumentBuilderFactory documentBuilderFactory =
135-
DocumentBuilderFactory.newInstance();
133+
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
136134
documentBuilderFactory.setNamespaceAware(true);
137135
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
138136

spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,8 +27,7 @@
2727
public class StaxEventHandlerTests extends AbstractStaxHandlerTestCase {
2828

2929
@Override
30-
protected AbstractStaxHandler createStaxHandler(Result result)
31-
throws XMLStreamException {
30+
protected AbstractStaxHandler createStaxHandler(Result result) throws XMLStreamException {
3231
XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
3332
XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(result);
3433
return new StaxEventHandler(eventWriter);

spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,8 +27,7 @@
2727
public class StaxStreamHandlerTests extends AbstractStaxHandlerTestCase {
2828

2929
@Override
30-
protected AbstractStaxHandler createStaxHandler(Result result)
31-
throws XMLStreamException {
30+
protected AbstractStaxHandler createStaxHandler(Result result) throws XMLStreamException {
3231
XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
3332
XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(result);
3433
return new StaxStreamHandler(streamWriter);

spring-oxm/src/main/java/org/springframework/oxm/Marshaller.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,15 +35,15 @@
3535
public interface Marshaller {
3636

3737
/**
38-
* Indicates whether this marshaller can marshal instances of the supplied type.
38+
* Indicate whether this marshaller can marshal instances of the supplied type.
3939
* @param clazz the class that this marshaller is being asked if it can marshal
4040
* @return {@code true} if this marshaller can indeed marshal instances of the supplied class;
4141
* {@code false} otherwise
4242
*/
4343
boolean supports(Class<?> clazz);
4444

4545
/**
46-
* Marshals the object graph with the given root into the provided {@link Result}.
46+
* Marshal the object graph with the given root into the provided {@link Result}.
4747
* @param graph the root of the object graph to marshal
4848
* @param result the result to marshal to
4949
* @throws IOException if an I/O error occurs

spring-oxm/src/main/java/org/springframework/oxm/Unmarshaller.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,15 +30,15 @@
3030
public interface Unmarshaller {
3131

3232
/**
33-
* Indicates whether this unmarshaller can unmarshal instances of the supplied type.
33+
* Indicate whether this unmarshaller can unmarshal instances of the supplied type.
3434
* @param clazz the class that this unmarshaller is being asked if it can marshal
3535
* @return {@code true} if this unmarshaller can indeed unmarshal to the supplied class;
3636
* {@code false} otherwise
3737
*/
3838
boolean supports(Class<?> clazz);
3939

4040
/**
41-
* Unmarshals the given {@link Source} into an object graph.
41+
* Unmarshal the given {@link Source} into an object graph.
4242
* @param source the source to marshal from
4343
* @return the object graph
4444
* @throws IOException if an I/O error occurs

0 commit comments

Comments
 (0)