Search in sources :

Example 1 with ObjectSetterFactory

use of org.simpleflatmapper.reflect.ObjectSetterFactory in project SimpleFlatMapper by arnaudroger.

the class ObjectGetterFactoryTest method testExtension.

@Test
public void testExtension() throws Exception {
    Foo foo = new Foo();
    new ObjectSetterFactory(null).getSetter(Foo.class, "bar").set(foo, "bar");
    new ObjectSetterFactory(null).getFieldSetter(Foo.class, "bar").set(foo, "bar");
    assertEquals("bar", noAsm.getGetter(Foo.class, "bar").get(foo));
    assertEquals("bar", noAsm.getFieldGetter(Foo.class, "bar").get(foo));
}
Also used : Foo(org.simpleflatmapper.test.beans.Foo) ObjectSetterFactory(org.simpleflatmapper.reflect.ObjectSetterFactory) Test(org.junit.Test)

Example 2 with ObjectSetterFactory

use of org.simpleflatmapper.reflect.ObjectSetterFactory in project SimpleFlatMapper by arnaudroger.

the class ObjectSetterFactoryTest method testFailFallBackToMethod.

@Test
public void testFailFallBackToMethod() throws Exception {
    Setter<Foo, String> setter = new ObjectSetterFactory(new AsmFactory(Thread.currentThread().getContextClassLoader()) {

        @Override
        public <T, P> Setter<T, P> createSetter(Method m) throws Exception {
            throw new UnsupportedOperationException();
        }
    }).getSetter(Foo.class, "foo");
    assertTrue(setter instanceof MethodSetter);
    SetterHelperTest.validateFooSetter(setter);
}
Also used : Foo(org.simpleflatmapper.test.beans.Foo) ObjectSetterFactory(org.simpleflatmapper.reflect.ObjectSetterFactory) CharacterMethodSetter(org.simpleflatmapper.reflect.primitive.CharacterMethodSetter) LongMethodSetter(org.simpleflatmapper.reflect.primitive.LongMethodSetter) ShortMethodSetter(org.simpleflatmapper.reflect.primitive.ShortMethodSetter) ByteMethodSetter(org.simpleflatmapper.reflect.primitive.ByteMethodSetter) BooleanMethodSetter(org.simpleflatmapper.reflect.primitive.BooleanMethodSetter) FloatMethodSetter(org.simpleflatmapper.reflect.primitive.FloatMethodSetter) IntMethodSetter(org.simpleflatmapper.reflect.primitive.IntMethodSetter) MethodSetter(org.simpleflatmapper.reflect.setter.MethodSetter) DoubleMethodSetter(org.simpleflatmapper.reflect.primitive.DoubleMethodSetter) AsmFactory(org.simpleflatmapper.reflect.asm.AsmFactory) Method(java.lang.reflect.Method) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 ObjectSetterFactory (org.simpleflatmapper.reflect.ObjectSetterFactory)2 Foo (org.simpleflatmapper.test.beans.Foo)2 Method (java.lang.reflect.Method)1 AsmFactory (org.simpleflatmapper.reflect.asm.AsmFactory)1 BooleanMethodSetter (org.simpleflatmapper.reflect.primitive.BooleanMethodSetter)1 ByteMethodSetter (org.simpleflatmapper.reflect.primitive.ByteMethodSetter)1 CharacterMethodSetter (org.simpleflatmapper.reflect.primitive.CharacterMethodSetter)1 DoubleMethodSetter (org.simpleflatmapper.reflect.primitive.DoubleMethodSetter)1 FloatMethodSetter (org.simpleflatmapper.reflect.primitive.FloatMethodSetter)1 IntMethodSetter (org.simpleflatmapper.reflect.primitive.IntMethodSetter)1 LongMethodSetter (org.simpleflatmapper.reflect.primitive.LongMethodSetter)1 ShortMethodSetter (org.simpleflatmapper.reflect.primitive.ShortMethodSetter)1 MethodSetter (org.simpleflatmapper.reflect.setter.MethodSetter)1