MethodParameter.equals checks nesting level and containing class
Closes gh-23352
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -39,6 +39,7 @@ import kotlin.reflect.jvm.ReflectJvmMapping;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Helper class that encapsulates the specification of a method parameter, i.e. a {@link Method}
|
||||
@@ -61,6 +62,7 @@ public class MethodParameter {
|
||||
|
||||
private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
|
||||
|
||||
|
||||
private final Executable executable;
|
||||
|
||||
private final int parameterIndex;
|
||||
@@ -68,7 +70,7 @@ public class MethodParameter {
|
||||
@Nullable
|
||||
private volatile Parameter parameter;
|
||||
|
||||
private int nestingLevel = 1;
|
||||
private int nestingLevel;
|
||||
|
||||
/** Map from Integer level to Integer type index. */
|
||||
@Nullable
|
||||
@@ -658,12 +660,16 @@ public class MethodParameter {
|
||||
return false;
|
||||
}
|
||||
MethodParameter otherParam = (MethodParameter) other;
|
||||
return (this.parameterIndex == otherParam.parameterIndex && getExecutable().equals(otherParam.getExecutable()));
|
||||
return (this.containingClass == otherParam.containingClass &&
|
||||
ObjectUtils.nullSafeEquals(this.typeIndexesPerLevel, otherParam.typeIndexesPerLevel) &&
|
||||
this.nestingLevel == otherParam.nestingLevel &&
|
||||
this.parameterIndex == otherParam.parameterIndex &&
|
||||
this.executable.equals(otherParam.executable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (getExecutable().hashCode() * 31 + this.parameterIndex);
|
||||
return (31 * this.executable.hashCode() + this.parameterIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user