Browse Source

Added @Override annotations to core module

conversation
Arjen Poutsma 16 years ago
parent
commit
564d4feba4
  1. 43
      org.springframework.core/pom.xml
  2. 10
      org.springframework.core/src/main/java/org/springframework/core/AttributeAccessorSupport.java
  3. 26
      org.springframework.core/src/main/java/org/springframework/core/CollectionFactory.java
  4. 10
      org.springframework.core/src/main/java/org/springframework/core/ConfigurableObjectInputStream.java
  5. 7
      org.springframework.core/src/main/java/org/springframework/core/ControlFlowFactory.java
  6. 26
      org.springframework.core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java
  7. 3
      org.springframework.core/src/main/java/org/springframework/core/NamedInheritableThreadLocal.java
  8. 3
      org.springframework.core/src/main/java/org/springframework/core/NamedThreadLocal.java
  9. 3
      org.springframework.core/src/main/java/org/springframework/core/NestedCheckedException.java
  10. 3
      org.springframework.core/src/main/java/org/springframework/core/NestedIOException.java
  11. 3
      org.springframework.core/src/main/java/org/springframework/core/NestedRuntimeException.java
  12. 7
      org.springframework.core/src/main/java/org/springframework/core/OverridingClassLoader.java
  13. 3
      org.springframework.core/src/main/java/org/springframework/core/annotation/AnnotationAwareOrderComparator.java
  14. 16
      org.springframework.core/src/main/java/org/springframework/core/enums/AbstractCachingLabeledEnumResolver.java
  15. 9
      org.springframework.core/src/main/java/org/springframework/core/enums/AbstractLabeledEnum.java
  16. 7
      org.springframework.core/src/main/java/org/springframework/core/enums/StaticLabeledEnumResolver.java
  17. 15
      org.springframework.core/src/main/java/org/springframework/core/io/AbstractResource.java
  18. 9
      org.springframework.core/src/main/java/org/springframework/core/io/ByteArrayResource.java
  19. 29
      org.springframework.core/src/main/java/org/springframework/core/io/ClassPathResource.java
  20. 9
      org.springframework.core/src/main/java/org/springframework/core/io/DefaultResourceLoader.java
  21. 12
      org.springframework.core/src/main/java/org/springframework/core/io/DescriptiveResource.java
  22. 33
      org.springframework.core/src/main/java/org/springframework/core/io/FileSystemResource.java
  23. 3
      org.springframework.core/src/main/java/org/springframework/core/io/FileSystemResourceLoader.java
  24. 12
      org.springframework.core/src/main/java/org/springframework/core/io/InputStreamResource.java
  25. 12
      org.springframework.core/src/main/java/org/springframework/core/io/ResourceEditor.java
  26. 32
      org.springframework.core/src/main/java/org/springframework/core/io/UrlResource.java
  27. 17
      org.springframework.core/src/main/java/org/springframework/core/io/support/EncodedResource.java
  28. 18
      org.springframework.core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java
  29. 3
      org.springframework.core/src/main/java/org/springframework/core/style/ToStringCreator.java
  30. 10
      org.springframework.core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java
  31. 22
      org.springframework.core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java
  32. 9
      org.springframework.core/src/main/java/org/springframework/core/type/classreading/CachingMetadataReaderFactory.java
  33. 10
      org.springframework.core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java
  34. 12
      org.springframework.core/src/main/java/org/springframework/util/AutoPopulatingList.java
  35. 13
      org.springframework.core/src/main/java/org/springframework/util/CachingMapDecorator.java
  36. 13
      org.springframework.core/src/main/java/org/springframework/util/CommonsLogWriter.java
  37. 3
      org.springframework.core/src/main/java/org/springframework/util/StopWatch.java
  38. 9
      org.springframework.core/src/main/java/org/springframework/util/comparator/BooleanComparator.java
  39. 13
      org.springframework.core/src/main/java/org/springframework/util/comparator/CompoundComparator.java
  40. 9
      org.springframework.core/src/main/java/org/springframework/util/comparator/InvertibleComparator.java
  41. 13
      org.springframework.core/src/main/java/org/springframework/util/comparator/NullSafeComparator.java

43
org.springframework.core/pom.xml

@ -1,58 +1,39 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.parent</artifactId>
<version>3.0-M1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.core</artifactId> <artifactId>org.springframework.core</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Spring Core Abstractions and Utilities</name> <name>Spring Framework: Core</name>
<version>3.0.0.M1</version>
<repositories>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies> <dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>com.springsource.org.apache.commons.logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.log4j</groupId> <groupId>org.apache.log4j</groupId>
<artifactId>com.springsource.org.apache.log4j</artifactId> <artifactId>com.springsource.org.apache.log4j</artifactId>
<version>1.2.15</version> <scope>compile</scope>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>com.springsource.org.apache.commons.collections</artifactId> <artifactId>com.springsource.org.apache.commons.collections</artifactId>
<version>3.2.0</version>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.aspectj</groupId> <groupId>org.aspectj</groupId>
<artifactId>com.springsource.org.aspectj.weaver</artifactId> <artifactId>com.springsource.org.aspectj.weaver</artifactId>
<version>1.6.2.RELEASE</version> <optional>true</optional>
</dependency>
<dependency>
<groupId>org.objectweb.asm</groupId>
<artifactId>com.springsource.org.objectweb.asm</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.objectweb.asm</groupId> <groupId>org.objectweb.asm</groupId>
<artifactId>com.springsource.org.objectweb.asm.commons</artifactId> <artifactId>com.springsource.org.objectweb.asm.commons</artifactId>
<version>2.2.3</version>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
</dependencies> </dependencies>

10
org.springframework.core/src/main/java/org/springframework/core/AttributeAccessorSupport.java

@ -16,13 +16,13 @@
package org.springframework.core; package org.springframework.core;
import org.springframework.util.Assert;
import java.io.Serializable; import java.io.Serializable;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.springframework.util.Assert;
/** /**
* Support class for {@link AttributeAccessor AttributeAccessors}, providing * Support class for {@link AttributeAccessor AttributeAccessors}, providing
* a base implementation of all methods. To be extended by subclasses. * a base implementation of all methods. To be extended by subclasses.
@ -84,7 +84,8 @@ public abstract class AttributeAccessorSupport implements AttributeAccessor, Ser
} }
public boolean equals(Object other) { @Override
public boolean equals(Object other) {
if (this == other) { if (this == other) {
return true; return true;
} }
@ -95,7 +96,8 @@ public abstract class AttributeAccessorSupport implements AttributeAccessor, Ser
return this.attributes.equals(that.attributes); return this.attributes.equals(that.attributes);
} }
public int hashCode() { @Override
public int hashCode() {
return this.attributes.hashCode(); return this.attributes.hashCode();
} }

26
org.springframework.core/src/main/java/org/springframework/core/CollectionFactory.java

@ -16,34 +16,16 @@
package org.springframework.core; package org.springframework.core;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
import java.util.NavigableSet;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import org.apache.commons.collections.map.CaseInsensitiveMap; import org.apache.commons.collections.map.CaseInsensitiveMap;
import org.apache.commons.collections.map.ListOrderedMap; import org.apache.commons.collections.map.ListOrderedMap;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
/** /**
* Factory for collections, being aware of Commons Collection 3.x's extended * Factory for collections, being aware of Commons Collection 3.x's extended
* collections as well as of JDK 1.5+ concurrent collections and backport-concurrent * collections as well as of JDK 1.5+ concurrent collections and backport-concurrent

10
org.springframework.core/src/main/java/org/springframework/core/ConfigurableObjectInputStream.java

@ -16,14 +16,14 @@
package org.springframework.core; package org.springframework.core;
import org.springframework.util.ClassUtils;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectStreamClass; import java.io.ObjectStreamClass;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import org.springframework.util.ClassUtils;
/** /**
* Special ObjectInputStream subclass that resolves class names * Special ObjectInputStream subclass that resolves class names
* against a specific ClassLoader. Serves as base class for * against a specific ClassLoader. Serves as base class for
@ -49,7 +49,8 @@ public class ConfigurableObjectInputStream extends ObjectInputStream {
} }
protected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException { @Override
protected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException {
try { try {
if (this.classLoader != null) { if (this.classLoader != null) {
// Use the specified ClassLoader to resolve local classes. // Use the specified ClassLoader to resolve local classes.
@ -65,7 +66,8 @@ public class ConfigurableObjectInputStream extends ObjectInputStream {
} }
} }
protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { @Override
protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException {
if (this.classLoader != null) { if (this.classLoader != null) {
// Use the specified ClassLoader to resolve local proxy classes. // Use the specified ClassLoader to resolve local proxy classes.
Class[] resolvedInterfaces = new Class[interfaces.length]; Class[] resolvedInterfaces = new Class[interfaces.length];

7
org.springframework.core/src/main/java/org/springframework/core/ControlFlowFactory.java

@ -16,11 +16,11 @@
package org.springframework.core; package org.springframework.core;
import org.springframework.util.Assert;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import org.springframework.util.Assert;
/** /**
* Static factory to conceal the automatic choice of the ControlFlow * Static factory to conceal the automatic choice of the ControlFlow
* implementation class. * implementation class.
@ -103,7 +103,8 @@ public abstract class ControlFlowFactory {
return stackTrace.indexOf(token) != -1; return stackTrace.indexOf(token) != -1;
} }
public String toString() { @Override
public String toString() {
StringBuffer sb = new StringBuffer("Jdk14ControlFlow: "); StringBuffer sb = new StringBuffer("Jdk14ControlFlow: ");
for (int i = 0; i < this.stack.length; i++) { for (int i = 0; i < this.stack.length; i++) {
if (i > 0) { if (i > 0) {

26
org.springframework.core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java

@ -16,6 +16,12 @@
package org.springframework.core; package org.springframework.core;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.objectweb.asm.*;
import org.objectweb.asm.commons.EmptyVisitor;
import org.springframework.util.ClassUtils;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -25,17 +31,6 @@ import java.lang.reflect.Modifier;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.commons.EmptyVisitor;
import org.springframework.util.ClassUtils;
/** /**
* Implementation of {@link ParameterNameDiscoverer} that uses the LocalVariableTable * Implementation of {@link ParameterNameDiscoverer} that uses the LocalVariableTable
* information in the method attributes to discover parameter names. Returns * information in the method attributes to discover parameter names. Returns
@ -177,7 +172,8 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD
this.descriptorToMatch = descriptor; this.descriptorToMatch = descriptor;
} }
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { @Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (name.equals(this.methodNameToMatch) && desc.equals(this.descriptorToMatch)) { if (name.equals(this.methodNameToMatch) && desc.equals(this.descriptorToMatch)) {
return new LocalVariableTableVisitor(this, isStatic(access)); return new LocalVariableTableVisitor(this, isStatic(access));
} }
@ -253,7 +249,8 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD
this.parameterNames = new String[memberVisitor.numParamsExpected]; this.parameterNames = new String[memberVisitor.numParamsExpected];
} }
public void visitLocalVariable( @Override
public void visitLocalVariable(
String name, String description, String signature, Label start, Label end, int index) { String name, String description, String signature, Label start, Label end, int index) {
this.hasLvtInfo = true; this.hasLvtInfo = true;
int[] lvtSlotIndices = this.memberVisitor.lvtSlotIndex; int[] lvtSlotIndices = this.memberVisitor.lvtSlotIndex;
@ -264,7 +261,8 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD
} }
} }
public void visitEnd() { @Override
public void visitEnd() {
if (this.hasLvtInfo || (this.isStatic && this.parameterNames.length == 0)) { if (this.hasLvtInfo || (this.isStatic && this.parameterNames.length == 0)) {
// visitLocalVariable will never be called for static no args methods // visitLocalVariable will never be called for static no args methods
// which doesn't use any local variables. // which doesn't use any local variables.

3
org.springframework.core/src/main/java/org/springframework/core/NamedInheritableThreadLocal.java

@ -40,7 +40,8 @@ public class NamedInheritableThreadLocal extends InheritableThreadLocal {
this.name = name; this.name = name;
} }
public String toString() { @Override
public String toString() {
return this.name; return this.name;
} }

3
org.springframework.core/src/main/java/org/springframework/core/NamedThreadLocal.java

@ -40,7 +40,8 @@ public class NamedThreadLocal extends ThreadLocal {
this.name = name; this.name = name;
} }
public String toString() { @Override
public String toString() {
return this.name; return this.name;
} }

3
org.springframework.core/src/main/java/org/springframework/core/NestedCheckedException.java

@ -63,7 +63,8 @@ public abstract class NestedCheckedException extends Exception {
* Return the detail message, including the message from the nested exception * Return the detail message, including the message from the nested exception
* if there is one. * if there is one.
*/ */
public String getMessage() { @Override
public String getMessage() {
return NestedExceptionUtils.buildMessage(super.getMessage(), getCause()); return NestedExceptionUtils.buildMessage(super.getMessage(), getCause());
} }

3
org.springframework.core/src/main/java/org/springframework/core/NestedIOException.java

@ -59,7 +59,8 @@ public class NestedIOException extends IOException {
* Return the detail message, including the message from the nested exception * Return the detail message, including the message from the nested exception
* if there is one. * if there is one.
*/ */
public String getMessage() { @Override
public String getMessage() {
return NestedExceptionUtils.buildMessage(super.getMessage(), getCause()); return NestedExceptionUtils.buildMessage(super.getMessage(), getCause());
} }

3
org.springframework.core/src/main/java/org/springframework/core/NestedRuntimeException.java

@ -63,7 +63,8 @@ public abstract class NestedRuntimeException extends RuntimeException {
* Return the detail message, including the message from the nested exception * Return the detail message, including the message from the nested exception
* if there is one. * if there is one.
*/ */
public String getMessage() { @Override
public String getMessage() {
return NestedExceptionUtils.buildMessage(super.getMessage(), getCause()); return NestedExceptionUtils.buildMessage(super.getMessage(), getCause());
} }

7
org.springframework.core/src/main/java/org/springframework/core/OverridingClassLoader.java

@ -16,11 +16,11 @@
package org.springframework.core; package org.springframework.core;
import org.springframework.util.FileCopyUtils;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import org.springframework.util.FileCopyUtils;
/** /**
* <code>ClassLoader</code> that does <i>not</i> always delegate to the * <code>ClassLoader</code> that does <i>not</i> always delegate to the
* parent loader, as normal class loaders do. This enables, for example, * parent loader, as normal class loaders do. This enables, for example,
@ -54,7 +54,8 @@ public class OverridingClassLoader extends DecoratingClassLoader {
} }
protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { @Override
protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
Class result = null; Class result = null;
if (isEligibleForOverriding(name)) { if (isEligibleForOverriding(name)) {
result = loadClassForOverriding(name); result = loadClassForOverriding(name);

3
org.springframework.core/src/main/java/org/springframework/core/annotation/AnnotationAwareOrderComparator.java

@ -33,7 +33,8 @@ import org.springframework.core.Ordered;
*/ */
public class AnnotationAwareOrderComparator extends OrderComparator { public class AnnotationAwareOrderComparator extends OrderComparator {
protected int getOrder(Object obj) { @Override
protected int getOrder(Object obj) {
if (obj instanceof Ordered) { if (obj instanceof Ordered) {
return ((Ordered) obj).getOrder(); return ((Ordered) obj).getOrder();
} }

16
org.springframework.core/src/main/java/org/springframework/core/enums/AbstractCachingLabeledEnumResolver.java

@ -16,20 +16,14 @@
package org.springframework.core.enums; package org.springframework.core.enums;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.CachingMapDecorator; import org.springframework.util.CachingMapDecorator;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import java.util.*;
/** /**
* Abstract base class for {@link LabeledEnumResolver} implementations, * Abstract base class for {@link LabeledEnumResolver} implementations,
* caching all retrieved {@link LabeledEnum} instances. * caching all retrieved {@link LabeledEnum} instances.
@ -48,7 +42,8 @@ public abstract class AbstractCachingLabeledEnumResolver implements LabeledEnumR
private final CachingMapDecorator labeledEnumCache = new CachingMapDecorator(true) { private final CachingMapDecorator labeledEnumCache = new CachingMapDecorator(true) {
protected Object create(Object key) { @Override
protected Object create(Object key) {
Class enumType = (Class) key; Class enumType = (Class) key;
Set typeEnums = findLabeledEnums(enumType); Set typeEnums = findLabeledEnums(enumType);
if (typeEnums == null || typeEnums.isEmpty()) { if (typeEnums == null || typeEnums.isEmpty()) {
@ -64,7 +59,8 @@ public abstract class AbstractCachingLabeledEnumResolver implements LabeledEnumR
} }
return Collections.unmodifiableMap(typeEnumMap); return Collections.unmodifiableMap(typeEnumMap);
} }
protected boolean useWeakValue(Object key, Object value) { @Override
protected boolean useWeakValue(Object key, Object value) {
Class enumType = (Class) key; Class enumType = (Class) key;
if (!ClassUtils.isCacheSafe(enumType, AbstractCachingLabeledEnumResolver.this.getClass().getClassLoader())) { if (!ClassUtils.isCacheSafe(enumType, AbstractCachingLabeledEnumResolver.this.getClass().getClassLoader())) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {

9
org.springframework.core/src/main/java/org/springframework/core/enums/AbstractLabeledEnum.java

@ -49,7 +49,8 @@ public abstract class AbstractLabeledEnum implements LabeledEnum {
return this.getCode().compareTo(that.getCode()); return this.getCode().compareTo(that.getCode());
} }
public boolean equals(Object obj) { @Override
public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
@ -60,11 +61,13 @@ public abstract class AbstractLabeledEnum implements LabeledEnum {
return (this.getType().equals(other.getType()) && this.getCode().equals(other.getCode())); return (this.getType().equals(other.getType()) && this.getCode().equals(other.getCode()));
} }
public int hashCode() { @Override
public int hashCode() {
return (getType().hashCode() * 29 + getCode().hashCode()); return (getType().hashCode() * 29 + getCode().hashCode());
} }
public String toString() { @Override
public String toString() {
return getLabel(); return getLabel();
} }

7
org.springframework.core/src/main/java/org/springframework/core/enums/StaticLabeledEnumResolver.java

@ -16,13 +16,13 @@
package org.springframework.core.enums; package org.springframework.core.enums;
import org.springframework.util.Assert;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import org.springframework.util.Assert;
/** /**
* {@link LabeledEnumResolver} that resolves statically defined enumerations. * {@link LabeledEnumResolver} that resolves statically defined enumerations.
* Static implies all enum instances were defined within Java code, * Static implies all enum instances were defined within Java code,
@ -50,7 +50,8 @@ public class StaticLabeledEnumResolver extends AbstractCachingLabeledEnumResolve
} }
protected Set findLabeledEnums(Class type) { @Override
protected Set findLabeledEnums(Class type) {
Set typeEnums = new TreeSet(); Set typeEnums = new TreeSet();
Field[] fields = type.getFields(); Field[] fields = type.getFields();
for (int i = 0; i < fields.length; i++) { for (int i = 0; i < fields.length; i++) {

15
org.springframework.core/src/main/java/org/springframework/core/io/AbstractResource.java

@ -16,6 +16,9 @@
package org.springframework.core.io; package org.springframework.core.io;
import org.springframework.core.NestedIOException;
import org.springframework.util.ResourceUtils;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
@ -24,9 +27,6 @@ import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import org.springframework.core.NestedIOException;
import org.springframework.util.ResourceUtils;
/** /**
* Convenience base class for {@link Resource} implementations, * Convenience base class for {@link Resource} implementations,
* pre-implementing typical behavior. * pre-implementing typical behavior.
@ -153,7 +153,8 @@ public abstract class AbstractResource implements Resource {
* This implementation returns the description of this resource. * This implementation returns the description of this resource.
* @see #getDescription() * @see #getDescription()
*/ */
public String toString() { @Override
public String toString() {
return getDescription(); return getDescription();
} }
@ -161,7 +162,8 @@ public abstract class AbstractResource implements Resource {
* This implementation compares description strings. * This implementation compares description strings.
* @see #getDescription() * @see #getDescription()
*/ */
public boolean equals(Object obj) { @Override
public boolean equals(Object obj) {
return (obj == this || return (obj == this ||
(obj instanceof Resource && ((Resource) obj).getDescription().equals(getDescription()))); (obj instanceof Resource && ((Resource) obj).getDescription().equals(getDescription())));
} }
@ -170,7 +172,8 @@ public abstract class AbstractResource implements Resource {
* This implementation returns the description's hash code. * This implementation returns the description's hash code.
* @see #getDescription() * @see #getDescription()
*/ */
public int hashCode() { @Override
public int hashCode() {
return getDescription().hashCode(); return getDescription().hashCode();
} }

9
org.springframework.core/src/main/java/org/springframework/core/io/ByteArrayResource.java

@ -75,7 +75,8 @@ public class ByteArrayResource extends AbstractResource {
/** /**
* This implementation always returns <code>true</code>. * This implementation always returns <code>true</code>.
*/ */
public boolean exists() { @Override
public boolean exists() {
return true; return true;
} }
@ -100,7 +101,8 @@ public class ByteArrayResource extends AbstractResource {
* This implementation compares the underlying byte array. * This implementation compares the underlying byte array.
* @see java.util.Arrays#equals(byte[], byte[]) * @see java.util.Arrays#equals(byte[], byte[])
*/ */
public boolean equals(Object obj) { @Override
public boolean equals(Object obj) {
return (obj == this || return (obj == this ||
(obj instanceof ByteArrayResource && Arrays.equals(((ByteArrayResource) obj).byteArray, this.byteArray))); (obj instanceof ByteArrayResource && Arrays.equals(((ByteArrayResource) obj).byteArray, this.byteArray)));
} }
@ -109,7 +111,8 @@ public class ByteArrayResource extends AbstractResource {
* This implementation returns the hash code based on the * This implementation returns the hash code based on the
* underlying byte array. * underlying byte array.
*/ */
public int hashCode() { @Override
public int hashCode() {
return (byte[].class.hashCode() * 29 * this.byteArray.length); return (byte[].class.hashCode() * 29 * this.byteArray.length);
} }

29
org.springframework.core/src/main/java/org/springframework/core/io/ClassPathResource.java

@ -16,18 +16,14 @@
package org.springframework.core.io; package org.springframework.core.io;
import org.springframework.util.*;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.ResourceUtils;
import org.springframework.util.StringUtils;
/** /**
* {@link Resource} implementation for class path resources. * {@link Resource} implementation for class path resources.
* Uses either a given ClassLoader or a given Class for loading resources. * Uses either a given ClassLoader or a given Class for loading resources.
@ -151,7 +147,8 @@ public class ClassPathResource extends AbstractResource {
* @see java.lang.ClassLoader#getResource(String) * @see java.lang.ClassLoader#getResource(String)
* @see java.lang.Class#getResource(String) * @see java.lang.Class#getResource(String)
*/ */
public URL getURL() throws IOException { @Override
public URL getURL() throws IOException {
URL url = null; URL url = null;
if (this.clazz != null) { if (this.clazz != null) {
url = this.clazz.getResource(this.path); url = this.clazz.getResource(this.path);
@ -171,7 +168,8 @@ public class ClassPathResource extends AbstractResource {
* resource, provided that it refers to a file in the file system. * resource, provided that it refers to a file in the file system.
* @see org.springframework.util.ResourceUtils#getFile(java.net.URL, String) * @see org.springframework.util.ResourceUtils#getFile(java.net.URL, String)
*/ */
public File getFile() throws IOException { @Override
public File getFile() throws IOException {
return ResourceUtils.getFile(getURL(), getDescription()); return ResourceUtils.getFile(getURL(), getDescription());
} }
@ -179,7 +177,8 @@ public class ClassPathResource extends AbstractResource {
* This implementation determines the underlying File * This implementation determines the underlying File
* (or jar file, in case of a resource in a jar/zip). * (or jar file, in case of a resource in a jar/zip).
*/ */
protected File getFileForLastModifiedCheck() throws IOException { @Override
protected File getFileForLastModifiedCheck() throws IOException {
URL url = getURL(); URL url = getURL();
if (ResourceUtils.isJarURL(url)) { if (ResourceUtils.isJarURL(url)) {
URL actualUrl = ResourceUtils.extractJarFileURL(url); URL actualUrl = ResourceUtils.extractJarFileURL(url);
@ -195,7 +194,8 @@ public class ClassPathResource extends AbstractResource {
* relative to the path of the underlying resource of this descriptor. * relative to the path of the underlying resource of this descriptor.
* @see org.springframework.util.StringUtils#applyRelativePath(String, String) * @see org.springframework.util.StringUtils#applyRelativePath(String, String)
*/ */
public Resource createRelative(String relativePath) { @Override
public Resource createRelative(String relativePath) {
String pathToUse = StringUtils.applyRelativePath(this.path, relativePath); String pathToUse = StringUtils.applyRelativePath(this.path, relativePath);
return new ClassPathResource(pathToUse, this.classLoader, this.clazz); return new ClassPathResource(pathToUse, this.classLoader, this.clazz);
} }
@ -205,7 +205,8 @@ public class ClassPathResource extends AbstractResource {
* resource refers to. * resource refers to.
* @see org.springframework.util.StringUtils#getFilename(String) * @see org.springframework.util.StringUtils#getFilename(String)
*/ */
public String getFilename() { @Override
public String getFilename() {
return StringUtils.getFilename(this.path); return StringUtils.getFilename(this.path);
} }
@ -220,7 +221,8 @@ public class ClassPathResource extends AbstractResource {
/** /**
* This implementation compares the underlying class path locations. * This implementation compares the underlying class path locations.
*/ */
public boolean equals(Object obj) { @Override
public boolean equals(Object obj) {
if (obj == this) { if (obj == this) {
return true; return true;
} }
@ -237,7 +239,8 @@ public class ClassPathResource extends AbstractResource {
* This implementation returns the hash code of the underlying * This implementation returns the hash code of the underlying
* class path location. * class path location.
*/ */
public int hashCode() { @Override
public int hashCode() {
return this.path.hashCode(); return this.path.hashCode();
} }

9
org.springframework.core/src/main/java/org/springframework/core/io/DefaultResourceLoader.java

@ -16,13 +16,13 @@
package org.springframework.core.io; package org.springframework.core.io;
import java.net.MalformedURLException;
import java.net.URL;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.net.MalformedURLException;
import java.net.URL;
/** /**
* Default implementation of the {@link ResourceLoader} interface. * Default implementation of the {@link ResourceLoader} interface.
* Used by {@link ResourceEditor}, and serves as base class for * Used by {@link ResourceEditor}, and serves as base class for
@ -134,7 +134,8 @@ public class DefaultResourceLoader implements ResourceLoader {
return getPath(); return getPath();
} }
public Resource createRelative(String relativePath) { @Override
public Resource createRelative(String relativePath) {
String pathToUse = StringUtils.applyRelativePath(getPath(), relativePath); String pathToUse = StringUtils.applyRelativePath(getPath(), relativePath);
return new ClassPathContextResource(pathToUse, getClassLoader()); return new ClassPathContextResource(pathToUse, getClassLoader());
} }

12
org.springframework.core/src/main/java/org/springframework/core/io/DescriptiveResource.java

@ -44,11 +44,13 @@ public class DescriptiveResource extends AbstractResource {
} }
public boolean exists() { @Override
public boolean exists() {
return false; return false;
} }
public boolean isReadable() { @Override
public boolean isReadable() {
return false; return false;
} }
@ -65,7 +67,8 @@ public class DescriptiveResource extends AbstractResource {
/** /**
* This implementation compares the underlying description String. * This implementation compares the underlying description String.
*/ */
public boolean equals(Object obj) { @Override
public boolean equals(Object obj) {
return (obj == this || return (obj == this ||
(obj instanceof DescriptiveResource && ((DescriptiveResource) obj).description.equals(this.description))); (obj instanceof DescriptiveResource && ((DescriptiveResource) obj).description.equals(this.description)));
} }
@ -73,7 +76,8 @@ public class DescriptiveResource extends AbstractResource {
/** /**
* This implementation returns the hash code of the underlying description String. * This implementation returns the hash code of the underlying description String.
*/ */
public int hashCode() { @Override
public int hashCode() {
return this.description.hashCode(); return this.description.hashCode();
} }

33
org.springframework.core/src/main/java/org/springframework/core/io/FileSystemResource.java

@ -16,6 +16,9 @@
package org.springframework.core.io; package org.springframework.core.io;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
@ -23,9 +26,6 @@ import java.io.InputStream;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/** /**
* {@link Resource} implementation for <code>java.io.File</code> handles. * {@link Resource} implementation for <code>java.io.File</code> handles.
* Obviously supports resolution as File, and also as URL. * Obviously supports resolution as File, and also as URL.
@ -86,7 +86,8 @@ public class FileSystemResource extends AbstractResource {
* This implementation returns whether the underlying file exists. * This implementation returns whether the underlying file exists.
* @see java.io.File#exists() * @see java.io.File#exists()
*/ */
public boolean exists() { @Override
public boolean exists() {
return this.file.exists(); return this.file.exists();
} }
@ -96,7 +97,8 @@ public class FileSystemResource extends AbstractResource {
* @see java.io.File#canRead() * @see java.io.File#canRead()
* @see java.io.File#isDirectory() * @see java.io.File#isDirectory()
*/ */
public boolean isReadable() { @Override
public boolean isReadable() {
return (this.file.canRead() && !this.file.isDirectory()); return (this.file.canRead() && !this.file.isDirectory());
} }
@ -112,7 +114,8 @@ public class FileSystemResource extends AbstractResource {
* This implementation returns a URL for the underlying file. * This implementation returns a URL for the underlying file.
* @see java.io.File#toURI() * @see java.io.File#toURI()
*/ */
public URL getURL() throws IOException { @Override
public URL getURL() throws IOException {
return this.file.toURI().toURL(); return this.file.toURI().toURL();
} }
@ -120,14 +123,16 @@ public class FileSystemResource extends AbstractResource {
* This implementation returns a URI for the underlying file. * This implementation returns a URI for the underlying file.
* @see java.io.File#toURI() * @see java.io.File#toURI()
*/ */
public URI getURI() throws IOException { @Override
public URI getURI() throws IOException {
return this.file.toURI(); return this.file.toURI();
} }
/** /**
* This implementation returns the underlying File reference. * This implementation returns the underlying File reference.
*/ */
public File getFile() { @Override
public File getFile() {
return this.file; return this.file;
} }
@ -136,7 +141,8 @@ public class FileSystemResource extends AbstractResource {
* relative to the path of the underlying file of this resource descriptor. * relative to the path of the underlying file of this resource descriptor.
* @see org.springframework.util.StringUtils#applyRelativePath(String, String) * @see org.springframework.util.StringUtils#applyRelativePath(String, String)
*/ */
public Resource createRelative(String relativePath) { @Override
public Resource createRelative(String relativePath) {
String pathToUse = StringUtils.applyRelativePath(this.path, relativePath); String pathToUse = StringUtils.applyRelativePath(this.path, relativePath);
return new FileSystemResource(pathToUse); return new FileSystemResource(pathToUse);
} }
@ -145,7 +151,8 @@ public class FileSystemResource extends AbstractResource {
* This implementation returns the name of the file. * This implementation returns the name of the file.
* @see java.io.File#getName() * @see java.io.File#getName()
*/ */
public String getFilename() { @Override
public String getFilename() {
return this.file.getName(); return this.file.getName();
} }
@ -162,7 +169,8 @@ public class FileSystemResource extends AbstractResource {
/** /**
* This implementation compares the underlying File references. * This implementation compares the underlying File references.
*/ */
public boolean equals(Object obj) { @Override
public boolean equals(Object obj) {
return (obj == this || return (obj == this ||
(obj instanceof FileSystemResource && this.path.equals(((FileSystemResource) obj).path))); (obj instanceof FileSystemResource && this.path.equals(((FileSystemResource) obj).path)));
} }
@ -170,7 +178,8 @@ public class FileSystemResource extends AbstractResource {
/** /**
* This implementation returns the hash code of the underlying File reference. * This implementation returns the hash code of the underlying File reference.
*/ */
public int hashCode() { @Override
public int hashCode() {
return this.path.hashCode(); return this.path.hashCode();
} }

3
org.springframework.core/src/main/java/org/springframework/core/io/FileSystemResourceLoader.java

@ -46,7 +46,8 @@ public class FileSystemResourceLoader extends DefaultResourceLoader {
* @see FileSystemResource * @see FileSystemResource
* @see org.springframework.web.context.support.ServletContextResourceLoader#getResourceByPath * @see org.springframework.web.context.support.ServletContextResourceLoader#getResourceByPath
*/ */
protected Resource getResourceByPath(String path) { @Override
protected Resource getResourceByPath(String path) {
if (path != null && path.startsWith("/")) { if (path != null && path.startsWith("/")) {
path = path.substring(1); path = path.substring(1);
} }

12
org.springframework.core/src/main/java/org/springframework/core/io/InputStreamResource.java

@ -71,14 +71,16 @@ public class InputStreamResource extends AbstractResource {
/** /**
* This implementation always returns <code>true</code>. * This implementation always returns <code>true</code>.
*/ */
public boolean exists() { @Override
public boolean exists() {
return true; return true;
} }
/** /**
* This implementation always returns <code>true</code>. * This implementation always returns <code>true</code>.
*/ */
public boolean isOpen() { @Override
public boolean isOpen() {
return true; return true;
} }
@ -106,7 +108,8 @@ public class InputStreamResource extends AbstractResource {
/** /**
* This implementation compares the underlying InputStream. * This implementation compares the underlying InputStream.
*/ */
public boolean equals(Object obj) { @Override
public boolean equals(Object obj) {
return (obj == this || return (obj == this ||
(obj instanceof InputStreamResource && ((InputStreamResource) obj).inputStream.equals(this.inputStream))); (obj instanceof InputStreamResource && ((InputStreamResource) obj).inputStream.equals(this.inputStream)));
} }
@ -114,7 +117,8 @@ public class InputStreamResource extends AbstractResource {
/** /**
* This implementation returns the hash code of the underlying InputStream. * This implementation returns the hash code of the underlying InputStream.
*/ */
public int hashCode() { @Override
public int hashCode() {
return this.inputStream.hashCode(); return this.inputStream.hashCode();
} }

12
org.springframework.core/src/main/java/org/springframework/core/io/ResourceEditor.java

@ -16,13 +16,13 @@
package org.springframework.core.io; package org.springframework.core.io;
import java.beans.PropertyEditorSupport;
import java.io.IOException;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.util.SystemPropertyUtils; import org.springframework.util.SystemPropertyUtils;
import java.beans.PropertyEditorSupport;
import java.io.IOException;
/** /**
* {@link java.beans.PropertyEditor Editor} for {@link Resource} * {@link java.beans.PropertyEditor Editor} for {@link Resource}
* descriptors, to automatically convert <code>String</code> locations * descriptors, to automatically convert <code>String</code> locations
@ -68,7 +68,8 @@ public class ResourceEditor extends PropertyEditorSupport {
} }
public void setAsText(String text) { @Override
public void setAsText(String text) {
if (StringUtils.hasText(text)) { if (StringUtils.hasText(text)) {
String locationToUse = resolvePath(text).trim(); String locationToUse = resolvePath(text).trim();
setValue(this.resourceLoader.getResource(locationToUse)); setValue(this.resourceLoader.getResource(locationToUse));
@ -90,7 +91,8 @@ public class ResourceEditor extends PropertyEditorSupport {
} }
public String getAsText() { @Override
public String getAsText() {
Resource value = (Resource) getValue(); Resource value = (Resource) getValue();
try { try {
// Try to determine URL for resource. // Try to determine URL for resource.

32
org.springframework.core/src/main/java/org/springframework/core/io/UrlResource.java

@ -16,6 +16,10 @@
package org.springframework.core.io; package org.springframework.core.io;
import org.springframework.util.Assert;
import org.springframework.util.ResourceUtils;
import org.springframework.util.StringUtils;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -24,10 +28,6 @@ import java.net.URI;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import org.springframework.util.Assert;
import org.springframework.util.ResourceUtils;
import org.springframework.util.StringUtils;
/** /**
* {@link Resource} implementation for <code>java.net.URL</code> locators. * {@link Resource} implementation for <code>java.net.URL</code> locators.
* Obviously supports resolution as URL, and also as File in case of * Obviously supports resolution as URL, and also as File in case of
@ -126,7 +126,8 @@ public class UrlResource extends AbstractResource {
/** /**
* This implementation returns the underlying URL reference. * This implementation returns the underlying URL reference.
*/ */
public URL getURL() throws IOException { @Override
public URL getURL() throws IOException {
return this.url; return this.url;
} }
@ -134,7 +135,8 @@ public class UrlResource extends AbstractResource {
* This implementation returns the underlying URI directly, * This implementation returns the underlying URI directly,
* if possible. * if possible.
*/ */
public URI getURI() throws IOException { @Override
public URI getURI() throws IOException {
if (this.uri != null) { if (this.uri != null) {
return this.uri; return this.uri;
} }
@ -148,7 +150,8 @@ public class UrlResource extends AbstractResource {
* provided that it refers to a file in the file system. * provided that it refers to a file in the file system.
* @see org.springframework.util.ResourceUtils#getFile(java.net.URL, String) * @see org.springframework.util.ResourceUtils#getFile(java.net.URL, String)
*/ */
public File getFile() throws IOException { @Override
public File getFile() throws IOException {
if (this.uri != null) { if (this.uri != null) {
return ResourceUtils.getFile(this.uri, getDescription()); return ResourceUtils.getFile(this.uri, getDescription());
} }
@ -161,7 +164,8 @@ public class UrlResource extends AbstractResource {
* This implementation determines the underlying File * This implementation determines the underlying File
* (or jar file, in case of a resource in a jar/zip). * (or jar file, in case of a resource in a jar/zip).
*/ */
protected File getFileForLastModifiedCheck() throws IOException { @Override
protected File getFileForLastModifiedCheck() throws IOException {
if (ResourceUtils.isJarURL(this.url)) { if (ResourceUtils.isJarURL(this.url)) {
URL actualUrl = ResourceUtils.extractJarFileURL(this.url); URL actualUrl = ResourceUtils.extractJarFileURL(this.url);
return ResourceUtils.getFile(actualUrl); return ResourceUtils.getFile(actualUrl);
@ -176,7 +180,8 @@ public class UrlResource extends AbstractResource {
* relative to the path of the underlying URL of this resource descriptor. * relative to the path of the underlying URL of this resource descriptor.
* @see java.net.URL#URL(java.net.URL, String) * @see java.net.URL#URL(java.net.URL, String)
*/ */
public Resource createRelative(String relativePath) throws MalformedURLException { @Override
public Resource createRelative(String relativePath) throws MalformedURLException {
if (relativePath.startsWith("/")) { if (relativePath.startsWith("/")) {
relativePath = relativePath.substring(1); relativePath = relativePath.substring(1);
} }
@ -188,7 +193,8 @@ public class UrlResource extends AbstractResource {
* @see java.net.URL#getFile() * @see java.net.URL#getFile()
* @see java.io.File#getName() * @see java.io.File#getName()
*/ */
public String getFilename() { @Override
public String getFilename() {
return new File(this.url.getFile()).getName(); return new File(this.url.getFile()).getName();
} }
@ -203,7 +209,8 @@ public class UrlResource extends AbstractResource {
/** /**
* This implementation compares the underlying URL references. * This implementation compares the underlying URL references.
*/ */
public boolean equals(Object obj) { @Override
public boolean equals(Object obj) {
return (obj == this || return (obj == this ||
(obj instanceof UrlResource && this.cleanedUrl.equals(((UrlResource) obj).cleanedUrl))); (obj instanceof UrlResource && this.cleanedUrl.equals(((UrlResource) obj).cleanedUrl)));
} }
@ -211,7 +218,8 @@ public class UrlResource extends AbstractResource {
/** /**
* This implementation returns the hash code of the underlying URL reference. * This implementation returns the hash code of the underlying URL reference.
*/ */
public int hashCode() { @Override
public int hashCode() {
return this.cleanedUrl.hashCode(); return this.cleanedUrl.hashCode();
} }

17
org.springframework.core/src/main/java/org/springframework/core/io/support/EncodedResource.java

@ -16,14 +16,14 @@
package org.springframework.core.io.support; package org.springframework.core.io.support;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
/** /**
* Holder that combines a {@link org.springframework.core.io.Resource} * Holder that combines a {@link org.springframework.core.io.Resource}
* with a specific encoding to be used for reading from the resource. * with a specific encoding to be used for reading from the resource.
@ -94,7 +94,8 @@ public class EncodedResource {
} }
public boolean equals(Object obj) { @Override
public boolean equals(Object obj) {
if (obj == this) { if (obj == this) {
return true; return true;
} }
@ -106,11 +107,13 @@ public class EncodedResource {
return false; return false;
} }
public int hashCode() { @Override
public int hashCode() {
return this.resource.hashCode(); return this.resource.hashCode();
} }
public String toString() { @Override
public String toString() {
return this.resource.toString(); return this.resource.toString();
} }

18
org.springframework.core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java

@ -16,17 +16,13 @@
package org.springframework.core.io.support; package org.springframework.core.io.support;
import java.beans.PropertyEditorSupport;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.util.SystemPropertyUtils; import org.springframework.util.SystemPropertyUtils;
import java.beans.PropertyEditorSupport;
import java.io.IOException;
import java.util.*;
/** /**
* Editor for {@link org.springframework.core.io.Resource} arrays, to * Editor for {@link org.springframework.core.io.Resource} arrays, to
* automatically convert <code>String</code> location patterns * automatically convert <code>String</code> location patterns
@ -74,7 +70,8 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport {
/** /**
* Treat the given text as location pattern and convert it to a Resource array. * Treat the given text as location pattern and convert it to a Resource array.
*/ */
public void setAsText(String text) { @Override
public void setAsText(String text) {
String pattern = resolvePath(text).trim(); String pattern = resolvePath(text).trim();
try { try {
setValue(this.resourcePatternResolver.getResources(pattern)); setValue(this.resourcePatternResolver.getResources(pattern));
@ -89,7 +86,8 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport {
* Treat the given value as collection or array and convert it to a Resource array. * Treat the given value as collection or array and convert it to a Resource array.
* Considers String elements as location patterns, and takes Resource elements as-is. * Considers String elements as location patterns, and takes Resource elements as-is.
*/ */
public void setValue(Object value) throws IllegalArgumentException { @Override
public void setValue(Object value) throws IllegalArgumentException {
if (value instanceof Collection || (value instanceof Object[] && !(value instanceof Resource[]))) { if (value instanceof Collection || (value instanceof Object[] && !(value instanceof Resource[]))) {
Collection input = (value instanceof Collection ? (Collection) value : Arrays.asList((Object[]) value)); Collection input = (value instanceof Collection ? (Collection) value : Arrays.asList((Object[]) value));
List merged = new ArrayList(); List merged = new ArrayList();

3
org.springframework.core/src/main/java/org/springframework/core/style/ToStringCreator.java

@ -180,7 +180,8 @@ public class ToStringCreator {
/** /**
* Return the String representation that this ToStringCreator built. * Return the String representation that this ToStringCreator built.
*/ */
public String toString() { @Override
public String toString() {
this.styler.styleEnd(this.buffer, this.object); this.styler.styleEnd(this.buffer, this.object);
return this.buffer.toString(); return this.buffer.toString();
} }

10
org.springframework.core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java

@ -16,13 +16,13 @@
package org.springframework.core.task; package org.springframework.core.task;
import java.io.Serializable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.ConcurrencyThrottleSupport; import org.springframework.util.ConcurrencyThrottleSupport;
import org.springframework.util.CustomizableThreadCreator; import org.springframework.util.CustomizableThreadCreator;
import java.io.Serializable;
/** /**
* TaskExecutor implementation that fires up a new Thread for each task, * TaskExecutor implementation that fires up a new Thread for each task,
* executing it asynchronously. * executing it asynchronously.
@ -166,11 +166,13 @@ public class SimpleAsyncTaskExecutor extends CustomizableThreadCreator implement
*/ */
private static class ConcurrencyThrottleAdapter extends ConcurrencyThrottleSupport { private static class ConcurrencyThrottleAdapter extends ConcurrencyThrottleSupport {
protected void beforeAccess() { @Override
protected void beforeAccess() {
super.beforeAccess(); super.beforeAccess();
} }
protected void afterAccess() { @Override
protected void afterAccess() {
super.afterAccess(); super.afterAccess();
} }
} }

22
org.springframework.core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java

@ -16,20 +16,15 @@
package org.springframework.core.type.classreading; package org.springframework.core.type.classreading;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Type; import org.objectweb.asm.Type;
import org.objectweb.asm.commons.EmptyVisitor; import org.objectweb.asm.commons.EmptyVisitor;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.*;
/** /**
* ASM class visitor which looks for the class name and implemented types as * ASM class visitor which looks for the class name and implemented types as
* well as for the annotations defined on the class, exposing them through * well as for the annotations defined on the class, exposing them through
@ -54,15 +49,18 @@ class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisitor imple
} }
public AnnotationVisitor visitAnnotation(final String desc, boolean visible) { @Override
public AnnotationVisitor visitAnnotation(final String desc, boolean visible) {
final String className = Type.getType(desc).getClassName(); final String className = Type.getType(desc).getClassName();
final Map<String, Object> attributes = new LinkedHashMap<String, Object>(); final Map<String, Object> attributes = new LinkedHashMap<String, Object>();
return new EmptyVisitor() { return new EmptyVisitor() {
public void visit(String name, Object value) { @Override
public void visit(String name, Object value) {
// Explicitly defined annotation attribute value. // Explicitly defined annotation attribute value.
attributes.put(name, value); attributes.put(name, value);
} }
public void visitEnd() { @Override
public void visitEnd() {
try { try {
Class annotationClass = classLoader.loadClass(className); Class annotationClass = classLoader.loadClass(className);
// Check declared default values of attributes in the annotation type. // Check declared default values of attributes in the annotation type.

9
org.springframework.core/src/main/java/org/springframework/core/type/classreading/CachingMetadataReaderFactory.java

@ -16,13 +16,13 @@
package org.springframework.core.type.classreading; package org.springframework.core.type.classreading;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
/** /**
* Caching implementation of the {@link MetadataReaderFactory} interface, * Caching implementation of the {@link MetadataReaderFactory} interface,
* caching an ASM {@link org.objectweb.asm.ClassReader} per Spring Resource handle * caching an ASM {@link org.objectweb.asm.ClassReader} per Spring Resource handle
@ -61,7 +61,8 @@ public class CachingMetadataReaderFactory extends SimpleMetadataReaderFactory {
} }
public MetadataReader getMetadataReader(Resource resource) throws IOException { @Override
public MetadataReader getMetadataReader(Resource resource) throws IOException {
synchronized (this.classReaderCache) { synchronized (this.classReaderCache) {
MetadataReader metadataReader = this.classReaderCache.get(resource); MetadataReader metadataReader = this.classReaderCache.get(resource);
if (metadataReader == null) { if (metadataReader == null) {

10
org.springframework.core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java

@ -18,7 +18,6 @@ package org.springframework.core.type.classreading;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
import org.objectweb.asm.commons.EmptyVisitor; import org.objectweb.asm.commons.EmptyVisitor;
import org.springframework.core.type.ClassMetadata; import org.springframework.core.type.ClassMetadata;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
@ -50,7 +49,8 @@ class ClassMetadataReadingVisitor extends EmptyVisitor implements ClassMetadata
private String[] interfaces; private String[] interfaces;
public void visit(int version, int access, String name, String signature, String supername, String[] interfaces) { @Override
public void visit(int version, int access, String name, String signature, String supername, String[] interfaces) {
this.className = ClassUtils.convertResourcePathToClassName(name); this.className = ClassUtils.convertResourcePathToClassName(name);
this.isInterface = ((access & Opcodes.ACC_INTERFACE) != 0); this.isInterface = ((access & Opcodes.ACC_INTERFACE) != 0);
this.isAbstract = ((access & Opcodes.ACC_ABSTRACT) != 0); this.isAbstract = ((access & Opcodes.ACC_ABSTRACT) != 0);
@ -63,11 +63,13 @@ class ClassMetadataReadingVisitor extends EmptyVisitor implements ClassMetadata
} }
} }
public void visitOuterClass(String owner, String name, String desc) { @Override
public void visitOuterClass(String owner, String name, String desc) {
this.enclosingClassName = ClassUtils.convertResourcePathToClassName(owner); this.enclosingClassName = ClassUtils.convertResourcePathToClassName(owner);
} }
public void visitInnerClass(String name, String outerName, String innerName, int access) { @Override
public void visitInnerClass(String name, String outerName, String innerName, int access) {
if (outerName != null && this.className.equals(ClassUtils.convertResourcePathToClassName(name))) { if (outerName != null && this.className.equals(ClassUtils.convertResourcePathToClassName(name))) {
this.enclosingClassName = ClassUtils.convertResourcePathToClassName(outerName); this.enclosingClassName = ClassUtils.convertResourcePathToClassName(outerName);
this.independentInnerClass = ((access & Opcodes.ACC_STATIC) != 0); this.independentInnerClass = ((access & Opcodes.ACC_STATIC) != 0);

12
org.springframework.core/src/main/java/org/springframework/util/AutoPopulatingList.java

@ -18,11 +18,7 @@ package org.springframework.util;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
/** /**
* Simple {@link List} wrapper class that allows for elements to be * Simple {@link List} wrapper class that allows for elements to be
@ -119,7 +115,8 @@ public class AutoPopulatingList implements List, Serializable {
return this.backingList.containsAll(c); return this.backingList.containsAll(c);
} }
public boolean equals(Object o) { @Override
public boolean equals(Object o) {
return this.backingList.equals(o); return this.backingList.equals(o);
} }
@ -148,7 +145,8 @@ public class AutoPopulatingList implements List, Serializable {
return element; return element;
} }
public int hashCode() { @Override
public int hashCode() {
return this.backingList.hashCode(); return this.backingList.hashCode();
} }

13
org.springframework.core/src/main/java/org/springframework/util/CachingMapDecorator.java

@ -19,15 +19,7 @@ package org.springframework.util;
import java.io.Serializable; import java.io.Serializable;
import java.lang.ref.Reference; import java.lang.ref.Reference;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.Collection; import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
/** /**
* A simple decorator for a Map, encapsulating the workflow for caching * A simple decorator for a Map, encapsulating the workflow for caching
@ -269,7 +261,8 @@ public class CachingMapDecorator implements Map, Serializable {
} }
public String toString() { @Override
public String toString() {
return "CachingMapDecorator [" + getClass().getName() + "]:" + this.targetMap; return "CachingMapDecorator [" + getClass().getName() + "]:" + this.targetMap;
} }

13
org.springframework.core/src/main/java/org/springframework/util/CommonsLogWriter.java

@ -16,10 +16,10 @@
package org.springframework.util; package org.springframework.util;
import java.io.Writer;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import java.io.Writer;
/** /**
* <code>java.io.Writer</code> adapter for a Commons Logging <code>Log</code>. * <code>java.io.Writer</code> adapter for a Commons Logging <code>Log</code>.
* *
@ -53,7 +53,8 @@ public class CommonsLogWriter extends Writer {
} }
} }
public void write(char[] buffer, int offset, int length) { @Override
public void write(char[] buffer, int offset, int length) {
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
char ch = buffer[offset + i]; char ch = buffer[offset + i];
if (ch == '\n' && this.buffer.length() > 0) { if (ch == '\n' && this.buffer.length() > 0) {
@ -66,10 +67,12 @@ public class CommonsLogWriter extends Writer {
} }
} }
public void flush() { @Override
public void flush() {
} }
public void close() { @Override
public void close() {
} }
} }

3
org.springframework.core/src/main/java/org/springframework/util/StopWatch.java

@ -232,7 +232,8 @@ public class StopWatch {
* Return an informative string describing all tasks performed * Return an informative string describing all tasks performed
* For custom reporting, call <code>getTaskInfo()</code> and use the task info directly. * For custom reporting, call <code>getTaskInfo()</code> and use the task info directly.
*/ */
public String toString() { @Override
public String toString() {
StringBuffer sb = new StringBuffer(shortSummary()); StringBuffer sb = new StringBuffer(shortSummary());
if (this.keepTaskList) { if (this.keepTaskList) {
TaskInfo[] tasks = getTaskInfo(); TaskInfo[] tasks = getTaskInfo();

9
org.springframework.core/src/main/java/org/springframework/util/comparator/BooleanComparator.java

@ -64,7 +64,8 @@ public final class BooleanComparator implements Comparator, Serializable {
return (v1 ^ v2) ? ((v1 ^ this.trueLow) ? 1 : -1) : 0; return (v1 ^ v2) ? ((v1 ^ this.trueLow) ? 1 : -1) : 0;
} }
public boolean equals(Object obj) { @Override
public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
@ -74,11 +75,13 @@ public final class BooleanComparator implements Comparator, Serializable {
return (this.trueLow == ((BooleanComparator) obj).trueLow); return (this.trueLow == ((BooleanComparator) obj).trueLow);
} }
public int hashCode() { @Override
public int hashCode() {
return (this.trueLow ? -1 : 1) * getClass().hashCode(); return (this.trueLow ? -1 : 1) * getClass().hashCode();
} }
public String toString() { @Override
public String toString() {
return "BooleanComparator: " + (this.trueLow ? "true low" : "true high"); return "BooleanComparator: " + (this.trueLow ? "true low" : "true high");
} }

13
org.springframework.core/src/main/java/org/springframework/util/comparator/CompoundComparator.java

@ -16,14 +16,14 @@
package org.springframework.util.comparator; package org.springframework.util.comparator;
import org.springframework.util.Assert;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.springframework.util.Assert;
/** /**
* A comparator that chains a sequence of one or more more Comparators. * A comparator that chains a sequence of one or more more Comparators.
* *
@ -184,7 +184,8 @@ public class CompoundComparator implements Comparator, Serializable {
return 0; return 0;
} }
public boolean equals(Object obj) { @Override
public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
@ -195,11 +196,13 @@ public class CompoundComparator implements Comparator, Serializable {
return this.comparators.equals(other.comparators); return this.comparators.equals(other.comparators);
} }
public int hashCode() { @Override
public int hashCode() {
return this.comparators.hashCode(); return this.comparators.hashCode();
} }
public String toString() { @Override
public String toString() {
return "CompoundComparator: " + this.comparators; return "CompoundComparator: " + this.comparators;
} }

9
org.springframework.core/src/main/java/org/springframework/util/comparator/InvertibleComparator.java

@ -96,7 +96,8 @@ public class InvertibleComparator implements Comparator, Serializable {
return 0; return 0;
} }
public boolean equals(Object obj) { @Override
public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
@ -107,11 +108,13 @@ public class InvertibleComparator implements Comparator, Serializable {
return (this.comparator.equals(other.comparator) && this.ascending == other.ascending); return (this.comparator.equals(other.comparator) && this.ascending == other.ascending);
} }
public int hashCode() { @Override
public int hashCode() {
return this.comparator.hashCode(); return this.comparator.hashCode();
} }
public String toString() { @Override
public String toString() {
return "InvertibleComparator: [" + this.comparator + "]; ascending=" + this.ascending; return "InvertibleComparator: [" + this.comparator + "]; ascending=" + this.ascending;
} }

13
org.springframework.core/src/main/java/org/springframework/util/comparator/NullSafeComparator.java

@ -16,10 +16,10 @@
package org.springframework.util.comparator; package org.springframework.util.comparator;
import java.util.Comparator;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import java.util.Comparator;
/** /**
* A Comparator that will safely compare nulls to be lower or higher than * A Comparator that will safely compare nulls to be lower or higher than
* other objects. Can decorate a given Comparator or work on Comparables. * other objects. Can decorate a given Comparator or work on Comparables.
@ -96,7 +96,8 @@ public class NullSafeComparator implements Comparator {
return this.nonNullComparator.compare(o1, o2); return this.nonNullComparator.compare(o1, o2);
} }
public boolean equals(Object obj) { @Override
public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
@ -107,11 +108,13 @@ public class NullSafeComparator implements Comparator {
return (this.nonNullComparator.equals(other.nonNullComparator) && this.nullsLow == other.nullsLow); return (this.nonNullComparator.equals(other.nonNullComparator) && this.nullsLow == other.nullsLow);
} }
public int hashCode() { @Override
public int hashCode() {
return (this.nullsLow ? -1 : 1) * this.nonNullComparator.hashCode(); return (this.nullsLow ? -1 : 1) * this.nonNullComparator.hashCode();
} }
public String toString() { @Override
public String toString() {
return "NullSafeComparator: non-null comparator [" + this.nonNullComparator + "]; " + return "NullSafeComparator: non-null comparator [" + this.nonNullComparator + "]; " +
(this.nullsLow ? "nulls low" : "nulls high"); (this.nullsLow ? "nulls low" : "nulls high");
} }

Loading…
Cancel
Save