Consistent bracket alignment
This commit is contained in:
@@ -155,7 +155,7 @@ abstract class SerializableTypeWrapper {
|
||||
return provider.getType();
|
||||
}
|
||||
Type cached = cache.get(provider.getType());
|
||||
if(cached != null) {
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
for (Class<?> type : SUPPORTED_SERIALIZABLE_TYPES) {
|
||||
|
||||
@@ -118,7 +118,7 @@ public final class Property {
|
||||
}
|
||||
|
||||
Annotation[] getAnnotations() {
|
||||
if(this.annotations == null) {
|
||||
if (this.annotations == null) {
|
||||
this.annotations = resolveAnnotations();
|
||||
}
|
||||
return this.annotations;
|
||||
@@ -192,7 +192,7 @@ public final class Property {
|
||||
|
||||
private Annotation[] resolveAnnotations() {
|
||||
Annotation[] annotations = annotationCache.get(this);
|
||||
if(annotations == null) {
|
||||
if (annotations == null) {
|
||||
Map<Class<? extends Annotation>, Annotation> annotationMap = new LinkedHashMap<Class<? extends Annotation>, Annotation>();
|
||||
addAnnotationsToMap(annotationMap, getReadMethod());
|
||||
addAnnotationsToMap(annotationMap, getWriteMethod());
|
||||
|
||||
@@ -78,7 +78,7 @@ final class MapToMapConverter implements ConditionalGenericConverter {
|
||||
copyRequired = true;
|
||||
}
|
||||
}
|
||||
if(!copyRequired) {
|
||||
if (!copyRequired) {
|
||||
return sourceMap;
|
||||
}
|
||||
Map<Object, Object> targetMap = CollectionFactory.createMap(targetType.getType(), sourceMap.size());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -28,7 +28,8 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Converts a comma-delimited String to a Collection.
|
||||
* If the target collection element type is declared, only matches if String.class can be converted to it.
|
||||
* If the target collection element type is declared, only matches if
|
||||
* {@code String.class} can be converted to it.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
@@ -37,10 +38,12 @@ final class StringToCollectionConverter implements ConditionalGenericConverter {
|
||||
|
||||
private final ConversionService conversionService;
|
||||
|
||||
|
||||
public StringToCollectionConverter(ConversionService conversionService) {
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<ConvertiblePair> getConvertibleTypes() {
|
||||
return Collections.singleton(new ConvertiblePair(String.class, Collection.class));
|
||||
@@ -48,11 +51,8 @@ final class StringToCollectionConverter implements ConditionalGenericConverter {
|
||||
|
||||
@Override
|
||||
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
if (targetType.getElementTypeDescriptor() != null) {
|
||||
return this.conversionService.canConvert(sourceType, targetType.getElementTypeDescriptor());
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return (targetType.getElementTypeDescriptor() == null ||
|
||||
this.conversionService.canConvert(sourceType, targetType.getElementTypeDescriptor()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,7 +67,8 @@ final class StringToCollectionConverter implements ConditionalGenericConverter {
|
||||
for (String field : fields) {
|
||||
target.add(field.trim());
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
for (String field : fields) {
|
||||
Object targetElement = this.conversionService.convert(field.trim(), sourceType, targetType.getElementTypeDescriptor());
|
||||
target.add(targetElement);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -18,7 +18,6 @@ package org.springframework.core.convert.support;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.convert.converter.ConverterFactory;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Converts from a String to a java.lang.Enum by calling {@link Enum#valueOf(Class, String)}.
|
||||
@@ -32,14 +31,16 @@ final class StringToEnumConverterFactory implements ConverterFactory<String, Enu
|
||||
@Override
|
||||
public <T extends Enum> Converter<String, T> getConverter(Class<T> targetType) {
|
||||
Class<?> enumType = targetType;
|
||||
while(enumType != null && !enumType.isEnum()) {
|
||||
while (enumType != null && !enumType.isEnum()) {
|
||||
enumType = enumType.getSuperclass();
|
||||
}
|
||||
Assert.notNull(enumType, "The target type " + targetType.getName()
|
||||
+ " does not refer to an enum");
|
||||
if (enumType == null) {
|
||||
throw new IllegalArgumentException("The target type " + targetType.getName() + " does not refer to an enum");
|
||||
}
|
||||
return new StringToEnum(enumType);
|
||||
}
|
||||
|
||||
|
||||
private class StringToEnum<T extends Enum> implements Converter<String, T> {
|
||||
|
||||
private final Class<T> enumType;
|
||||
|
||||
@@ -31,7 +31,7 @@ final class StringToUUIDConverter implements Converter<String, UUID> {
|
||||
|
||||
@Override
|
||||
public UUID convert(String source) {
|
||||
if(StringUtils.hasLength(source)) {
|
||||
if (StringUtils.hasLength(source)) {
|
||||
return UUID.fromString(source.trim());
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -129,7 +129,7 @@ public abstract class AbstractResource implements Resource {
|
||||
long size = 0;
|
||||
byte[] buf = new byte[255];
|
||||
int read;
|
||||
while((read = is.read(buf)) != -1) {
|
||||
while ((read = is.read(buf)) != -1) {
|
||||
size += read;
|
||||
}
|
||||
return size;
|
||||
|
||||
@@ -226,7 +226,7 @@ public class PathResource extends AbstractResource implements WritableResource {
|
||||
*/
|
||||
@Override
|
||||
public OutputStream getOutputStream() throws IOException {
|
||||
if(Files.isDirectory(this.path)) {
|
||||
if (Files.isDirectory(this.path)) {
|
||||
throw new FileNotFoundException(getPath() + " (is a directory)");
|
||||
}
|
||||
return Files.newOutputStream(this.path);
|
||||
|
||||
@@ -709,16 +709,16 @@ public class AntPathMatcher implements PathMatcher {
|
||||
protected void initCounters() {
|
||||
int pos = 0;
|
||||
while (pos < this.pattern.length()) {
|
||||
if(this.pattern.charAt(pos) == '{') {
|
||||
if (this.pattern.charAt(pos) == '{') {
|
||||
this.uriVars++;
|
||||
pos++;
|
||||
}
|
||||
else if(this.pattern.charAt(pos) == '*') {
|
||||
if(pos + 1 < this.pattern.length() && this.pattern.charAt(pos + 1) == '*') {
|
||||
else if (this.pattern.charAt(pos) == '*') {
|
||||
if (pos + 1 < this.pattern.length() && this.pattern.charAt(pos + 1) == '*') {
|
||||
this.doubleWildcards++;
|
||||
pos += 2;
|
||||
}
|
||||
else if(!this.pattern.substring(pos - 1).equals(".*")) {
|
||||
else if (!this.pattern.substring(pos - 1).equals(".*")) {
|
||||
this.singleWildcards++;
|
||||
pos++;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public abstract class ObjectUtils {
|
||||
*/
|
||||
public static <E extends Enum<?>> E caseInsensitiveValueOf(E[] enumValues, String constant) {
|
||||
for (E candidate : enumValues) {
|
||||
if(candidate.toString().equalsIgnoreCase(constant)) {
|
||||
if (candidate.toString().equalsIgnoreCase(constant)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -58,25 +58,18 @@ public abstract class SocketUtils {
|
||||
/**
|
||||
* Although {@code SocketUtils} consists solely of static utility methods,
|
||||
* this constructor is intentionally {@code public}.
|
||||
*
|
||||
* <h4>Rationale</h4>
|
||||
*
|
||||
* <p>Static methods from this class may be invoked from within XML
|
||||
* configuration files using the Spring Expression Language (SpEL) and the
|
||||
* following syntax.
|
||||
*
|
||||
* <pre><code><bean id="bean1" ... p:port="#{T(org.springframework.util.SocketUtils).findAvailableTcpPort(12000)}" /></code></pre>
|
||||
*
|
||||
* If this constructor were {@code private}, you would be required to supply
|
||||
* the fully qualified class name to SpEL's {@code T()} function for each usage.
|
||||
* Thus, the fact that this constructor is {@code public} allows you to reduce
|
||||
* boilerplate configuration with SpEL as can be seen in the following example.
|
||||
*
|
||||
* <pre><code><bean id="socketUtils" class="org.springframework.util.SocketUtils" />
|
||||
*
|
||||
*<bean id="bean1" ... p:port="#{socketUtils.findAvailableTcpPort(12000)}" />
|
||||
*
|
||||
*<bean id="bean2" ... p:port="#{socketUtils.findAvailableTcpPort(30000)}" /></code></pre>
|
||||
* <bean id="bean1" ... p:port="#{socketUtils.findAvailableTcpPort(12000)}" />
|
||||
* <bean id="bean2" ... p:port="#{socketUtils.findAvailableTcpPort(30000)}" /></code></pre>
|
||||
*/
|
||||
public SocketUtils() {
|
||||
/* no-op */
|
||||
@@ -271,7 +264,8 @@ public abstract class SocketUtils {
|
||||
maxPort, searchCounter));
|
||||
}
|
||||
candidatePort = findRandomPort(minPort, maxPort);
|
||||
} while (!isPortAvailable(candidatePort));
|
||||
}
|
||||
while (!isPortAvailable(candidatePort));
|
||||
|
||||
return candidatePort;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -229,7 +229,8 @@ public class StopWatch {
|
||||
sb.append('\n');
|
||||
if (!this.keepTaskList) {
|
||||
sb.append("No task info kept");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sb.append("-----------------------------------------\n");
|
||||
sb.append("ms % Task name\n");
|
||||
sb.append("-----------------------------------------\n");
|
||||
@@ -261,7 +262,8 @@ public class StopWatch {
|
||||
long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds());
|
||||
sb.append(" = ").append(percent).append("%");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sb.append("; no task info kept");
|
||||
}
|
||||
return sb.toString();
|
||||
|
||||
@@ -60,7 +60,7 @@ public class InstanceComparator<T> implements Comparator<T> {
|
||||
}
|
||||
|
||||
private int getOrder(T object) {
|
||||
if(object != null) {
|
||||
if (object != null) {
|
||||
for (int i = 0; i < instanceOrder.length; i++) {
|
||||
if (instanceOrder[i].isInstance(object)) {
|
||||
return i;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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,10 +29,10 @@ import org.springframework.util.Assert;
|
||||
* #get()} and {@link #get(long, TimeUnit)} call {@link #adapt(Object)} on the adaptee's
|
||||
* result.
|
||||
*
|
||||
* @param <T> the type of this {@code Future}
|
||||
* @param <S> the type of the adaptee's {@code Future}
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.0
|
||||
* @param <T> the type of this {@code Future}
|
||||
* @param <S> the type of the adaptee's {@code Future}
|
||||
*/
|
||||
public abstract class FutureAdapter<T, S> implements Future<T> {
|
||||
|
||||
@@ -44,6 +44,7 @@ public abstract class FutureAdapter<T, S> implements Future<T> {
|
||||
|
||||
private final Object mutex = new Object();
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new {@code FutureAdapter} with the given adaptee.
|
||||
* @param adaptee the future to delegate to
|
||||
@@ -53,6 +54,7 @@ public abstract class FutureAdapter<T, S> implements Future<T> {
|
||||
this.adaptee = adaptee;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the adaptee.
|
||||
*/
|
||||
@@ -81,28 +83,28 @@ public abstract class FutureAdapter<T, S> implements Future<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(long timeout, TimeUnit unit)
|
||||
throws InterruptedException, ExecutionException, TimeoutException {
|
||||
return adaptInternal(adaptee.get(timeout, unit));
|
||||
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
|
||||
return adaptInternal(this.adaptee.get(timeout, unit));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final T adaptInternal(S adapteeResult) throws ExecutionException {
|
||||
synchronized (mutex) {
|
||||
switch (state) {
|
||||
synchronized (this.mutex) {
|
||||
switch (this.state) {
|
||||
case SUCCESS:
|
||||
return (T) result;
|
||||
return (T) this.result;
|
||||
case FAILURE:
|
||||
throw (ExecutionException) result;
|
||||
throw (ExecutionException) this.result;
|
||||
case NEW:
|
||||
try {
|
||||
T adapted = adapt(adapteeResult);
|
||||
result = adapted;
|
||||
state = State.SUCCESS;
|
||||
this.result = adapted;
|
||||
this.state = State.SUCCESS;
|
||||
return adapted;
|
||||
} catch (ExecutionException ex) {
|
||||
result = ex;
|
||||
state = State.FAILURE;
|
||||
}
|
||||
catch (ExecutionException ex) {
|
||||
this.result = ex;
|
||||
this.state = State.FAILURE;
|
||||
throw ex;
|
||||
}
|
||||
default:
|
||||
@@ -117,6 +119,7 @@ public abstract class FutureAdapter<T, S> implements Future<T> {
|
||||
*/
|
||||
protected abstract T adapt(S adapteeResult) throws ExecutionException;
|
||||
|
||||
|
||||
private enum State {NEW, SUCCESS, FAILURE}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user