Skip to content

Commit 531318a

Browse files
committed
Polishing
1 parent a35b9c9 commit 531318a

File tree

3 files changed

+29
-31
lines changed

3 files changed

+29
-31
lines changed

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

Lines changed: 25 additions & 26 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.
@@ -310,14 +310,14 @@ public <T extends Annotation> T getParameterAnnotation(Class<T> annotationType)
310310
* Return true if the parameter has at least one annotation, false if it has none.
311311
*/
312312
public boolean hasParameterAnnotations() {
313-
return getParameterAnnotations().length != 0;
313+
return (getParameterAnnotations().length != 0);
314314
}
315315

316316
/**
317317
* Return true if the parameter has the given annotation type, and false if it doesn't.
318318
*/
319319
public <T extends Annotation> boolean hasParameterAnnotation(Class<T> annotationType) {
320-
return getParameterAnnotation(annotationType) != null;
320+
return (getParameterAnnotation(annotationType) != null);
321321
}
322322

323323
/**
@@ -416,28 +416,6 @@ private Map<Integer, Integer> getTypeIndexesPerLevel() {
416416
return this.typeIndexesPerLevel;
417417
}
418418

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

462-
463440
@Override
464441
public int hashCode() {
465442
int result = this.hash;
@@ -471,4 +448,26 @@ public int hashCode() {
471448
return result;
472449
}
473450

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+
474473
}

spring-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);

spring-webmvc/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)