replaced getParameterTypes().length with getParameterCount()

pull/539/head
Nitin 9 years ago
parent aa90bd62e0
commit 9a63ebf876

@ -81,7 +81,7 @@ public final class PropertyElf
Matcher matcher = GETTER_PATTERN.matcher("");
for (Method method : targetClass.getMethods()) {
String name = method.getName();
if (method.getParameterTypes().length == 0 && matcher.reset(name).matches()) {
if (method.getParameterCount() == 0 && matcher.reset(name).matches()) {
name = name.replaceFirst("(get|is)", "");
try {
if (targetClass.getMethod("set" + name, method.getReturnType()) != null) {
@ -132,7 +132,7 @@ public final class PropertyElf
String methodName = "set" + propName.substring(0, 1).toUpperCase() + propName.substring(1);
for (Method method : methods) {
if (method.getName().equals(methodName) && method.getParameterTypes().length == 1) {
if (method.getName().equals(methodName) && method.getParameterCount() == 1) {
writeMethod = method;
break;
}
@ -141,7 +141,7 @@ public final class PropertyElf
if (writeMethod == null) {
methodName = "set" + propName.toUpperCase();
for (Method method : methods) {
if (method.getName().equals(methodName) && method.getParameterTypes().length == 1) {
if (method.getName().equals(methodName) && method.getParameterCount() == 1) {
writeMethod = method;
break;
}

@ -73,18 +73,16 @@ public final class UtilityElf
try {
Class<?> loaded = UtilityElf.class.getClassLoader().loadClass(className);
if (args.length == 0) {
return clazz.cast(loaded.newInstance());
}
Class<?>[] argClasses = new Class<?>[args.length];
for (int i = 0; i < args.length; i++) {
argClasses[i] = args[i].getClass();
}
if (args.length > 0) {
Constructor<?> constructor = loaded.getConstructor(argClasses);
return clazz.cast(constructor.newInstance(args));
}
return clazz.cast(loaded.newInstance());
Constructor<?> constructor = loaded.getConstructor(argClasses);
return clazz.cast(constructor.newInstance(args));
}
catch (Exception e) {
throw new RuntimeException(e);

Loading…
Cancel
Save