Skip to content

Commit 12c4f8e

Browse files
committed
Polishing
1 parent b9ff29e commit 12c4f8e

File tree

5 files changed

+36
-39
lines changed

5 files changed

+36
-39
lines changed

org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -265,7 +265,7 @@ public LifecycleMetadata(Class<?> targetClass, Collection<LifecycleElement> init
265265
}
266266

267267
public void checkConfigMembers(RootBeanDefinition beanDefinition) {
268-
synchronized(this.initMethods) {
268+
synchronized (this.initMethods) {
269269
for (Iterator<LifecycleElement> it = this.initMethods.iterator(); it.hasNext();) {
270270
String methodIdentifier = it.next().getIdentifier();
271271
if (!beanDefinition.isExternallyManagedInitMethod(methodIdentifier)) {
@@ -276,7 +276,7 @@ public void checkConfigMembers(RootBeanDefinition beanDefinition) {
276276
}
277277
}
278278
}
279-
synchronized(this.destroyMethods) {
279+
synchronized (this.destroyMethods) {
280280
for (Iterator<LifecycleElement> it = this.destroyMethods.iterator(); it.hasNext();) {
281281
String methodIdentifier = it.next().getIdentifier();
282282
if (!beanDefinition.isExternallyManagedDestroyMethod(methodIdentifier)) {

org.springframework.core/src/main/java/org/springframework/core/MethodParameter.java

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -269,7 +269,6 @@ public Annotation[] getMethodAnnotations() {
269269
* @param annotationType the annotation type to look for
270270
* @return the annotation object, or <code>null</code> if not found
271271
*/
272-
@SuppressWarnings("unchecked")
273272
public <T extends Annotation> T getMethodAnnotation(Class<T> annotationType) {
274273
return getAnnotatedElement().getAnnotation(annotationType);
275274
}
@@ -311,14 +310,14 @@ public <T extends Annotation> T getParameterAnnotation(Class<T> annotationType)
311310
* Return true if the parameter has at least one annotation, false if it has none.
312311
*/
313312
public boolean hasParameterAnnotations() {
314-
return getParameterAnnotations().length != 0;
313+
return (getParameterAnnotations().length != 0);
315314
}
316315

317316
/**
318317
* Return true if the parameter has the given annotation type, and false if it doesn't.
319318
*/
320319
public <T extends Annotation> boolean hasParameterAnnotation(Class<T> annotationType) {
321-
return getParameterAnnotation(annotationType) != null;
320+
return (getParameterAnnotation(annotationType) != null);
322321
}
323322

324323
/**
@@ -417,28 +416,6 @@ private Map<Integer, Integer> getTypeIndexesPerLevel() {
417416
return this.typeIndexesPerLevel;
418417
}
419418

420-
421-
/**
422-
* Create a new MethodParameter for the given method or constructor.
423-
* <p>This is a convenience constructor for scenarios where a
424-
* Method or Constructor reference is treated in a generic fashion.
425-
* @param methodOrConstructor the Method or Constructor to specify a parameter for
426-
* @param parameterIndex the index of the parameter
427-
* @return the corresponding MethodParameter instance
428-
*/
429-
public static MethodParameter forMethodOrConstructor(Object methodOrConstructor, int parameterIndex) {
430-
if (methodOrConstructor instanceof Method) {
431-
return new MethodParameter((Method) methodOrConstructor, parameterIndex);
432-
}
433-
else if (methodOrConstructor instanceof Constructor) {
434-
return new MethodParameter((Constructor) methodOrConstructor, parameterIndex);
435-
}
436-
else {
437-
throw new IllegalArgumentException(
438-
"Given object [" + methodOrConstructor + "] is neither a Method nor a Constructor");
439-
}
440-
}
441-
442419
@Override
443420
public boolean equals(Object obj) {
444421
if (this == obj) {
@@ -460,7 +437,6 @@ else if (this.getMember().equals(other.getMember())) {
460437
return false;
461438
}
462439

463-
464440
@Override
465441
public int hashCode() {
466442
int result = this.hash;
@@ -472,4 +448,26 @@ public int hashCode() {
472448
return result;
473449
}
474450

451+
452+
/**
453+
* Create a new MethodParameter for the given method or constructor.
454+
* <p>This is a convenience constructor for scenarios where a
455+
* Method or Constructor reference is treated in a generic fashion.
456+
* @param methodOrConstructor the Method or Constructor to specify a parameter for
457+
* @param parameterIndex the index of the parameter
458+
* @return the corresponding MethodParameter instance
459+
*/
460+
public static MethodParameter forMethodOrConstructor(Object methodOrConstructor, int parameterIndex) {
461+
if (methodOrConstructor instanceof Method) {
462+
return new MethodParameter((Method) methodOrConstructor, parameterIndex);
463+
}
464+
else if (methodOrConstructor instanceof Constructor) {
465+
return new MethodParameter((Constructor) methodOrConstructor, parameterIndex);
466+
}
467+
else {
468+
throw new IllegalArgumentException(
469+
"Given object [" + methodOrConstructor + "] is neither a Method nor a Constructor");
470+
}
471+
}
472+
475473
}

org.springframework.core/src/test/java/org/springframework/core/MethodParameterTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@ public class MethodParameterTests {
3434

3535
private MethodParameter intReturnType;
3636

37+
3738
@Before
3839
public void setUp() throws NoSuchMethodException {
3940
Method method = getClass().getMethod("method", String.class, Long.TYPE);
@@ -42,8 +43,6 @@ public void setUp() throws NoSuchMethodException {
4243
intReturnType = new MethodParameter(method, -1);
4344
}
4445

45-
46-
4746
@Test
4847
public void testEquals() throws NoSuchMethodException {
4948
assertEquals(stringParameter, stringParameter);

org.springframework.expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public boolean canRead(EvaluationContext context, Object target, String name) th
8686
Field field = findField(name, type, target);
8787
if (field != null) {
8888
TypeDescriptor typeDescriptor = new TypeDescriptor(field);
89-
this.readerCache.put(cacheKey, new InvokerPair(field,typeDescriptor));
89+
this.readerCache.put(cacheKey, new InvokerPair(field, typeDescriptor));
9090
this.typeDescriptorCache.put(cacheKey, typeDescriptor);
9191
return true;
9292
}
@@ -264,15 +264,15 @@ private TypeDescriptor getTypeDescriptor(EvaluationContext context, Object targe
264264
return TypeDescriptor.valueOf(Integer.TYPE);
265265
}
266266
CacheKey cacheKey = new CacheKey(type, name);
267-
TypeDescriptor typeDescriptor = this.typeDescriptorCache.get(cacheKey);
267+
TypeDescriptor typeDescriptor = this.typeDescriptorCache.get(cacheKey);
268268
if (typeDescriptor == null) {
269269
// attempt to populate the cache entry
270270
try {
271271
if (canRead(context, target, name)) {
272-
typeDescriptor = this.typeDescriptorCache.get(cacheKey);
272+
typeDescriptor = this.typeDescriptorCache.get(cacheKey);
273273
}
274274
else if (canWrite(context, target, name)) {
275-
typeDescriptor = this.typeDescriptorCache.get(cacheKey);
275+
typeDescriptor = this.typeDescriptorCache.get(cacheKey);
276276
}
277277
}
278278
catch (AccessException ex) {

org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/multiaction/MultiActionController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -513,7 +513,7 @@ else if (returnValue instanceof String) {
513513
* @throws Exception if the command object could not be instantiated
514514
* @see org.springframework.beans.BeanUtils#instantiateClass(Class)
515515
*/
516-
protected Object newCommandObject(Class clazz) throws Exception {
516+
protected Object newCommandObject(Class<?> clazz) throws Exception {
517517
if (logger.isDebugEnabled()) {
518518
logger.debug("Creating new command of class [" + clazz.getName() + "]");
519519
}

0 commit comments

Comments
 (0)