Add constructor for more flexible signature

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@899532 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Pinaki Poddar 2010-01-15 05:26:43 +00:00
parent 342c27dfd5
commit ab032d8f73

View File

@ -120,8 +120,23 @@ public interface FillStrategy<T> {
try {
return cls.getConstructor(types);
} catch (Exception e) {
throw new RuntimeException(_loc.get("fill-ctor-none", cls, Arrays.toString(types)).getMessage());
Constructor<?>[] constructors = cls.getConstructors();
for (Constructor<?> cons : constructors) {
Class<?>[] paramTypes = cons.getParameterTypes();
boolean match = false;
if (paramTypes.length == types.length) {
for (int i = 0; i < paramTypes.length; i++) {
match = paramTypes[i].isAssignableFrom(Filters.wrap(types[i]));
if (!match)
break;
}
}
if (match) {
return (Constructor<X>)cons;
}
}
}
throw new RuntimeException(_loc.get("fill-ctor-none", cls, Arrays.toString(types)).getMessage());
}
public T fill(Object[] values, Class<?>[] types, String[] aliases) {