From 0891fbaf979aaa826db4db807a75cf6de54e74af Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 24 Mar 2016 19:54:28 +0100 Subject: [PATCH] Consistent formatting --- .../aspectj/AspectJAfterReturningAdvice.java | 4 +-- .../config/FieldRetrievingFactoryBean.java | 4 +-- .../beans/CollectingReaderEventListener.java | 33 ++++++++++--------- .../org/springframework/util/DigestUtils.java | 4 +-- .../org/springframework/util/MimeType.java | 4 +-- .../org/springframework/tests/Matchers.java | 2 +- .../org/springframework/tests/TestGroup.java | 3 +- .../expression/spel/CodeFlow.java | 2 +- .../jdbc/core/JdbcTemplate.java | 5 +-- .../cors/UrlBasedCorsConfigurationSource.java | 2 +- .../web/util/HierarchicalUriComponents.java | 6 ++-- .../servlet/resource/ResourceUrlProvider.java | 2 +- .../resource/VersionResourceResolver.java | 4 +-- .../frame/AbstractSockJsMessageCodec.java | 2 +- 14 files changed, 40 insertions(+), 37 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterReturningAdvice.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterReturningAdvice.java index 5e0b489c63..3a852bdb4f 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterReturningAdvice.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterReturningAdvice.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. @@ -98,7 +98,7 @@ public class AspectJAfterReturningAdvice extends AbstractAspectJAdvice implement else if (Object.class == type && void.class == method.getReturnType()) { return true; } - else{ + else { return ClassUtils.isAssignable(type, method.getReturnType()); } } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java index aca839616c..6f035c1732 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.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. @@ -204,7 +204,7 @@ public class FieldRetrievingFactoryBean // instance field return this.fieldObject.get(this.targetObject); } - else{ + else { // class field return this.fieldObject.get(null); } diff --git a/spring-beans/src/test/java/org/springframework/tests/beans/CollectingReaderEventListener.java b/spring-beans/src/test/java/org/springframework/tests/beans/CollectingReaderEventListener.java index b7fa67912c..1445c9944e 100644 --- a/spring-beans/src/test/java/org/springframework/tests/beans/CollectingReaderEventListener.java +++ b/spring-beans/src/test/java/org/springframework/tests/beans/CollectingReaderEventListener.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. @@ -36,20 +36,21 @@ import org.springframework.beans.factory.parsing.ReaderEventListener; */ public class CollectingReaderEventListener implements ReaderEventListener { - private final List defaults = new LinkedList(); + private final List defaults = new LinkedList<>(); - private final Map componentDefinitions = new LinkedHashMap<>(8); + private final Map componentDefinitions = new LinkedHashMap<>(8); - private final Map aliasMap = new LinkedHashMap<>(8); + private final Map> aliasMap = new LinkedHashMap<>(8); + + private final List imports = new LinkedList<>(); - private final List imports = new LinkedList(); @Override public void defaultsRegistered(DefaultsDefinition defaultsDefinition) { this.defaults.add(defaultsDefinition); } - public List getDefaults() { + public List getDefaults() { return Collections.unmodifiableList(this.defaults); } @@ -59,27 +60,27 @@ public class CollectingReaderEventListener implements ReaderEventListener { } public ComponentDefinition getComponentDefinition(String name) { - return (ComponentDefinition) this.componentDefinitions.get(name); + return this.componentDefinitions.get(name); } public ComponentDefinition[] getComponentDefinitions() { - Collection collection = this.componentDefinitions.values(); - return (ComponentDefinition[]) collection.toArray(new ComponentDefinition[collection.size()]); + Collection collection = this.componentDefinitions.values(); + return collection.toArray(new ComponentDefinition[collection.size()]); } @Override public void aliasRegistered(AliasDefinition aliasDefinition) { - List aliases = (List) this.aliasMap.get(aliasDefinition.getBeanName()); - if(aliases == null) { - aliases = new ArrayList(); + List aliases = this.aliasMap.get(aliasDefinition.getBeanName()); + if (aliases == null) { + aliases = new ArrayList<>(); this.aliasMap.put(aliasDefinition.getBeanName(), aliases); } aliases.add(aliasDefinition); } - public List getAliases(String beanName) { - List aliases = (List) this.aliasMap.get(beanName); - return aliases == null ? null : Collections.unmodifiableList(aliases); + public List getAliases(String beanName) { + List aliases = this.aliasMap.get(beanName); + return (aliases != null ? Collections.unmodifiableList(aliases) : null); } @Override @@ -87,7 +88,7 @@ public class CollectingReaderEventListener implements ReaderEventListener { this.imports.add(importDefinition); } - public List getImports() { + public List getImports() { return Collections.unmodifiableList(this.imports); } diff --git a/spring-core/src/main/java/org/springframework/util/DigestUtils.java b/spring-core/src/main/java/org/springframework/util/DigestUtils.java index 87ca6b852e..8de0b513cd 100644 --- a/spring-core/src/main/java/org/springframework/util/DigestUtils.java +++ b/spring-core/src/main/java/org/springframework/util/DigestUtils.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. @@ -127,7 +127,7 @@ public abstract class DigestUtils { ((UpdateMessageDigestInputStream) inputStream).updateMessageDigest(messageDigest); return messageDigest.digest(); } - else{ + else { return messageDigest.digest(StreamUtils.copyToByteArray(inputStream)); } } diff --git a/spring-core/src/main/java/org/springframework/util/MimeType.java b/spring-core/src/main/java/org/springframework/util/MimeType.java index 0f770998f2..b3e585fbcc 100644 --- a/spring-core/src/main/java/org/springframework/util/MimeType.java +++ b/spring-core/src/main/java/org/springframework/util/MimeType.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. @@ -180,7 +180,7 @@ public class MimeType implements Comparable, Serializable { * @see HTTP 1.1, section 2.2 */ private void checkToken(String token) { - for (int i=0; i < token.length(); i++ ) { + for (int i = 0; i < token.length(); i++ ) { char ch = token.charAt(i); if (!TOKEN.get(ch)) { throw new IllegalArgumentException("Invalid token character '" + ch + "' in token \"" + token + "\""); diff --git a/spring-core/src/test/java/org/springframework/tests/Matchers.java b/spring-core/src/test/java/org/springframework/tests/Matchers.java index 826bd1c732..346836cbb6 100644 --- a/spring-core/src/test/java/org/springframework/tests/Matchers.java +++ b/spring-core/src/test/java/org/springframework/tests/Matchers.java @@ -51,7 +51,7 @@ public class Matchers { @Override public boolean matches(Object item) { Throwable cause = null; - if(item != null && item instanceof Throwable) { + if (item != null && item instanceof Throwable) { cause = ((Throwable)item).getCause(); } return matcher.matches(cause); diff --git a/spring-core/src/test/java/org/springframework/tests/TestGroup.java b/spring-core/src/test/java/org/springframework/tests/TestGroup.java index aaf310f406..f7b8525bc6 100644 --- a/spring-core/src/test/java/org/springframework/tests/TestGroup.java +++ b/spring-core/src/test/java/org/springframework/tests/TestGroup.java @@ -93,7 +93,8 @@ public enum TestGroup { for (String group : value.split(",")) { try { groups.add(valueOf(group.trim().toUpperCase())); - } catch (IllegalArgumentException e) { + } + catch (IllegalArgumentException ex) { throw new IllegalArgumentException(format( "Unable to find test group '%s' when parsing testGroups value: '%s'. " + "Available groups include: [%s]", group.trim(), value, diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java b/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java index ad8c65daa0..2d20e195d1 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java @@ -918,7 +918,7 @@ public class CodeFlow implements Opcodes { */ public static boolean isReferenceTypeArray(String arraytype) { int length = arraytype.length(); - for (int i=0;i entry : this.corsConfigurations.entrySet()) { + for (Map.Entry entry : this.corsConfigurations.entrySet()) { if (this.pathMatcher.match(entry.getKey(), lookupPath)) { return entry.getValue(); } diff --git a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java index 7966e32fec..e25466ecbd 100644 --- a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java +++ b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.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. @@ -288,7 +288,7 @@ final class HierarchicalUriComponents extends UriComponents { return; } int length = source.length(); - for (int i=0; i < length; i++) { + for (int i = 0; i < length; i++) { char ch = source.charAt(i); if (ch == '%') { if ((i + 2) < length) { @@ -701,9 +701,9 @@ final class HierarchicalUriComponents extends UriComponents { public int hashCode() { return getPath().hashCode(); } - } + /** * Represents a path backed by a string list (i.e. path segments). */ diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java index 5537a48cdc..9ee0c5a8b7 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java @@ -218,7 +218,7 @@ public class ResourceUrlProvider implements ApplicationListener patternComparator = getPathMatcher().getPatternComparator(lookupPath); Collections.sort(matchingPatterns, patternComparator); - for(String pattern : matchingPatterns) { + for (String pattern : matchingPatterns) { String pathWithinMapping = getPathMatcher().extractPathWithinPattern(pattern, lookupPath); String pathMapping = lookupPath.substring(0, lookupPath.indexOf(pathWithinMapping)); if (logger.isTraceEnabled()) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java index 7ccc938ced..f7eb7cb014 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java @@ -123,9 +123,9 @@ public class VersionResourceResolver extends AbstractResourceResolver { List patternsList = Arrays.asList(pathPatterns); List prefixedPatterns = new ArrayList(pathPatterns.length); String versionPrefix = "/" + version; - for(String pattern : patternsList) { + for (String pattern : patternsList) { prefixedPatterns.add(pattern); - if(!pattern.startsWith(versionPrefix) && !patternsList.contains(versionPrefix + pattern)) { + if (!pattern.startsWith(versionPrefix) && !patternsList.contains(versionPrefix + pattern)) { prefixedPatterns.add(versionPrefix + pattern); } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java index a7481fe768..e2dfcb12d0 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java @@ -32,7 +32,7 @@ public abstract class AbstractSockJsMessageCodec implements SockJsMessageCodec { Assert.notNull(messages, "messages must not be null"); StringBuilder sb = new StringBuilder(); sb.append("a["); - for (int i=0; i < messages.length; i++) { + for (int i = 0; i < messages.length; i++) { sb.append('"'); char[] quotedChars = applyJsonQuoting(messages[i]); sb.append(escapeSockJsSpecialChars(quotedChars));