Replace occurrences of getParameterTypes().length and getParameters().length with getParameterCount()

Closes #10333
This commit is contained in:
Clara Fang 2022-02-19 22:28:26 -05:00 committed by Hynek Mlnařík
parent b66115c1df
commit bc27c7c464
6 changed files with 10 additions and 10 deletions

View file

@ -163,7 +163,7 @@ public class JBossWebPrincipalFactory implements PrincipalFactory {
static Constructor findJBossGenericPrincipalConstructor() {
for (Constructor<?> c : JBossGenericPrincipal.class.getConstructors()) {
if (c.getParameterTypes().length == 9 &&
if (c.getParameterCount() == 9 &&
c.getParameterTypes()[0].equals(Realm.class) &&
c.getParameterTypes()[1].equals(String.class) &&
c.getParameterTypes()[3].equals(List.class) &&

View file

@ -163,9 +163,9 @@ public class Types {
if (method == intfMethod) return true;
if (!method.getName().equals(intfMethod.getName())) return false;
if (method.getParameterTypes().length != intfMethod.getParameterTypes().length) return false;
if (method.getParameterCount() != intfMethod.getParameterCount()) return false;
for (int i = 0; i < method.getParameterTypes().length; i++)
for (int i = 0; i < method.getParameterCount(); i++)
{
Class rootParam = method.getParameterTypes()[i];
Class intfParam = intfMethod.getParameterTypes()[i];

View file

@ -323,7 +323,7 @@ public class LDAPUtils {
@Override
public boolean methodMatches(Method m) {
if ((m.getName().startsWith("get") || m.getName().startsWith("is"))
&& m.getParameterTypes().length > 0) {
&& m.getParameterCount() > 0) {
return false;
}

View file

@ -49,7 +49,7 @@ class MethodPropertyImpl<V> implements MethodProperty<V> {
if (method.getReturnType() == Void.TYPE) {
throw new IllegalArgumentException(
"Invalid accessor method, must have return value if starts with 'get'. Method: " + method);
} else if (method.getParameterTypes().length > 0) {
} else if (method.getParameterCount() > 0) {
throw new IllegalArgumentException(
"Invalid accessor method, must have zero arguments if starts with 'get'. Method: " + method);
}
@ -59,7 +59,7 @@ class MethodPropertyImpl<V> implements MethodProperty<V> {
if (method.getReturnType() != Void.TYPE) {
throw new IllegalArgumentException(
"Invalid accessor method, must not have return value if starts with 'set'. Method: " + method);
} else if (method.getParameterTypes().length != 1) {
} else if (method.getParameterCount() != 1) {
throw new IllegalArgumentException(
"Invalid accessor method, must have one argument if starts with 'set'. Method: " + method);
}
@ -151,7 +151,7 @@ class MethodPropertyImpl<V> implements MethodProperty<V> {
Method[] methods = clazz.getMethods();
for (Method method : methods) {
String methodName = method.getName();
if (methodName.startsWith(SETTER_METHOD_PREFIX) && method.getParameterTypes().length == 1) {
if (methodName.startsWith(SETTER_METHOD_PREFIX) && method.getParameterCount() == 1) {
if (Introspector.decapitalize(methodName.substring(SETTER_METHOD_PREFIX_LENGTH)).equals(name)) {
return method;
}
@ -163,7 +163,7 @@ class MethodPropertyImpl<V> implements MethodProperty<V> {
private static Method getGetterMethod(Class<?> clazz, String name) {
for (Method method : clazz.getDeclaredMethods()) {
String methodName = method.getName();
if (method.getParameterTypes().length == 0) {
if (method.getParameterCount() == 0) {
if (methodName.startsWith(GETTER_METHOD_PREFIX)) {
if (Introspector.decapitalize(methodName.substring(GETTER_METHOD_PREFIX_LENGTH)).equals(name)) {
return method;

View file

@ -1973,7 +1973,7 @@ public class PermissionsTest extends AbstractKeycloakTest {
List<String> ignoreList = Arrays.asList(ignore);
for (Method m : rep.getClass().getDeclaredMethods()) {
if (m.getParameters().length == 0 && m.getName().startsWith("get") && !ignoreList.contains(m.getName())) {
if (m.getParameterCount() == 0 && m.getName().startsWith("get") && !ignoreList.contains(m.getName())) {
try {
Object o = m.invoke(rep);
assertNull("Expected " + m.getName() + " to be null", o);

View file

@ -276,7 +276,7 @@ public class MultiVersionClusterTest extends AbstractClusterTest {
if (Arrays.asList(classForName.getDeclaredConstructors()).stream()
.filter(c -> !c.isSynthetic())
.anyMatch(c -> c.getParameterTypes().length == 0 )) {
.anyMatch(c -> c.getParameterCount() == 0 )) {
newInstance = Reflections.newInstance(classForName);
} else {
Constructor<?> constructor = Arrays.asList(classForName.getDeclaredConstructors()).stream()