DATACMNS-99 - SimpleTypeHolder considers complex Enums as simple now.

Fixed SimpleTypeHolder.isSimpleType(Class<?> type) for calls where the Class object handed in is derived from an Enum that implements an abstract method. These Class objects return false for a call to isEnum(). So an ….isAssignableFrom(…) check is safer.
This commit is contained in:
Oliver Gierke
2011-11-23 11:51:25 +01:00
parent 904578d034
commit 1468ba5735
2 changed files with 33 additions and 1 deletions

View File

@@ -92,4 +92,35 @@ public class SimpleTypeHolderUnitTests {
SimpleTypeHolder holder = new SimpleTypeHolder();
assertThat(holder.isSimpleType(Object.class), is(true));
}
@Test
public void considersSimpleEnumAsSimple() {
SimpleTypeHolder holder = new SimpleTypeHolder();
assertThat(holder.isSimpleType(SimpleEnum.FOO.getClass()), is(true));
}
@Test
public void considersComplexEnumAsSimple() {
SimpleTypeHolder holder = new SimpleTypeHolder();
assertThat(holder.isSimpleType(ComplexEnum.FOO.getClass()), is(true));
}
enum SimpleEnum {
FOO;
}
enum ComplexEnum {
FOO {
@Override
boolean method() {
return false;
}
};
abstract boolean method();
}
}