Java Code Examples for java.lang.reflect.Parameter#equals()

The following examples show how to use java.lang.reflect.Parameter#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MethodParameter.java    From spring-analysis-note with MIT License 6 votes vote down vote up
protected static int findParameterIndex(Parameter parameter) {
	Executable executable = parameter.getDeclaringExecutable();
	Parameter[] allParams = executable.getParameters();
	// Try first with identity checks for greater performance.
	for (int i = 0; i < allParams.length; i++) {
		if (parameter == allParams[i]) {
			return i;
		}
	}
	// Potentially try again with object equality checks in order to avoid race
	// conditions while invoking java.lang.reflect.Executable.getParameters().
	for (int i = 0; i < allParams.length; i++) {
		if (parameter.equals(allParams[i])) {
			return i;
		}
	}
	throw new IllegalArgumentException("Given parameter [" + parameter +
			"] does not match any parameter in the declaring executable");
}
 
Example 2
Source File: MethodParameter.java    From java-technology-stack with MIT License 6 votes vote down vote up
protected static int findParameterIndex(Parameter parameter) {
	Executable executable = parameter.getDeclaringExecutable();
	Parameter[] allParams = executable.getParameters();
	// Try first with identity checks for greater performance.
	for (int i = 0; i < allParams.length; i++) {
		if (parameter == allParams[i]) {
			return i;
		}
	}
	// Potentially try again with object equality checks in order to avoid race
	// conditions while invoking java.lang.reflect.Executable.getParameters().
	for (int i = 0; i < allParams.length; i++) {
		if (parameter.equals(allParams[i])) {
			return i;
		}
	}
	throw new IllegalArgumentException("Given parameter [" + parameter +
			"] does not match any parameter in the declaring executable");
}