Skip to content

Commit

Permalink
Improve normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
timowest committed Jan 9, 2016
1 parent 175b266 commit eed0456
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -86,6 +86,10 @@ private static Class<?> normalize(Class<?> cl) {
return cl.isPrimitive() ? Primitives.wrap(cl) : cl;
}

private static boolean isAssignableFrom(Class<?> cl1, Class<?> cl2) {
return normalize(cl1).isAssignableFrom(normalize(cl2));
}

private final ImmutableMap<String, Expression<?>> bindings;

private final List<Field> fields;
Expand Down Expand Up @@ -156,7 +160,7 @@ private List<Field> initFields(Map<String, ? extends Expression<?>> args) {
try {
field = beanType.getDeclaredField(property);
field.setAccessible(true);
if (!normalize(field.getType()).isAssignableFrom(expr.getType())) {
if (!isAssignableFrom(field.getType(), expr.getType())) {
typeMismatch(field.getType(), expr);
}
beanType = Object.class;
Expand Down Expand Up @@ -186,7 +190,7 @@ private List<Method> initMethods(Map<String, ? extends Expression<?>> args) {
for (PropertyDescriptor prop : propertyDescriptors) {
if (prop.getName().equals(property)) {
setter = prop.getWriteMethod();
if (!normalize(prop.getPropertyType()).isAssignableFrom(expr.getType())) {
if (!isAssignableFrom(prop.getPropertyType(), expr.getType())) {
typeMismatch(prop.getPropertyType(), expr);
}
break;
Expand Down

0 comments on commit eed0456

Please sign in to comment.