use of org.simpleflatmapper.reflect.meta.ArrayClassMeta in project SimpleFlatMapper by arnaudroger.
the class ListClassMetaTest method hasOneInstantiatorDefinitionWithEmptyConstructorOnImpl.
private void hasOneInstantiatorDefinitionWithEmptyConstructorOnImpl(ClassMeta<?> classMeta, Class<?> impl) throws NoSuchMethodException {
assertTrue(classMeta instanceof ArrayClassMeta);
final List<InstantiatorDefinition> instantiatorDefinitions = classMeta.getInstantiatorDefinitions();
assertEquals(1, instantiatorDefinitions.size());
final ExecutableInstantiatorDefinition instantiatorDefinition = (ExecutableInstantiatorDefinition) instantiatorDefinitions.get(0);
assertEquals(0, instantiatorDefinition.getParameters().length);
assertEquals(impl.getDeclaredConstructor(), instantiatorDefinition.getExecutable());
}
use of org.simpleflatmapper.reflect.meta.ArrayClassMeta in project SimpleFlatMapper by arnaudroger.
the class ArrayClassMetaTest method testSet.
private Object testSet(TypeReference<?> typeReference) throws Exception {
ClassMeta<?> classMeta = ReflectionService.newInstance().getClassMeta(typeReference.getType());
assertTrue(classMeta instanceof ArrayClassMeta);
PropertyMeta p = findProperty(classMeta);
Set<String> list = (Set<String>) instantiate(classMeta);
p.getSetter().set(list, "aaa");
assertEquals(null, p.getGetter().get(list));
assertEquals("aaa", list.iterator().next());
return list;
}
use of org.simpleflatmapper.reflect.meta.ArrayClassMeta in project SimpleFlatMapper by arnaudroger.
the class ArrayClassMetaTest method testArrayObject.
@Test
public void testArrayObject() throws Exception {
ClassMeta<?> classMeta = ReflectionService.newInstance().getClassMeta(Object[].class);
assertTrue(classMeta instanceof ArrayClassMeta);
PropertyMeta p = classMeta.newPropertyFinder(new Predicate() {
@Override
public boolean test(Object propertyMeta) {
return true;
}
}).findProperty(DefaultPropertyNameMatcher.of("3"), new Object[0]);
Object[] array = new Object[10];
p.getSetter().set(array, "aaa");
assertEquals("aaa", p.getGetter().get(array));
assertEquals("aaa", array[3]);
}
use of org.simpleflatmapper.reflect.meta.ArrayClassMeta in project SimpleFlatMapper by arnaudroger.
the class ArrayClassMetaTest method testArrayPrimitive.
private void testArrayPrimitive(Class<?> component, Object value) throws Exception {
assertTrue(component.isPrimitive());
Object array = Array.newInstance(component, 10);
ClassMeta<?> classMeta = ReflectionService.newInstance().getClassMeta(array.getClass());
assertTrue(classMeta instanceof ArrayClassMeta);
PropertyMeta p = classMeta.newPropertyFinder(new Predicate() {
@Override
public boolean test(Object propertyMeta) {
return true;
}
}).findProperty(DefaultPropertyNameMatcher.of("3"), new Object[0]);
p.getSetter().set(array, value);
assertEquals(value, p.getGetter().get(array));
assertEquals(value, Array.get(array, 3));
}
use of org.simpleflatmapper.reflect.meta.ArrayClassMeta in project SimpleFlatMapper by arnaudroger.
the class ArrayClassMetaTest method testGetterSetterOnList.
private Object testGetterSetterOnList(TypeReference<?> typeReference) throws Exception {
ClassMeta<?> classMeta = ReflectionService.newInstance().getClassMeta(typeReference.getType());
assertTrue(classMeta instanceof ArrayClassMeta);
PropertyMeta p = findProperty(classMeta);
Object list = instantiate(classMeta);
p.getSetter().set(list, "aaa");
assertEquals("aaa", p.getGetter().get(list));
return list;
}
Aggregations