Package org.apache.cayenne.reflect

Examples of org.apache.cayenne.reflect.FieldAccessor


    }

    public void testCopyObjectProperties() {
        PersistentDescriptor d1 = new PersistentDescriptor();

        FieldAccessor accessor = new FieldAccessor(TestBean.class, "string", String.class);
        Property property = new SimpleAttributeProperty(d1, accessor, null);

        d1.declaredProperties.put(property.getName(), property);

        TestBean from = new TestBean();
View Full Code Here


    static final String FAULT_FIELD_PREFIX = "$cay_faultResolved_";

    private Accessor faultResolvedFlagAccessor;

    EnhancedPojoPropertyFaultHandler(Class<?> objectClass, String propertyName) {
        this.faultResolvedFlagAccessor = new FieldAccessor(
                objectClass,
                FAULT_FIELD_PREFIX + propertyName,
                Boolean.TYPE);
    }
View Full Code Here

    static final String FAULT_FIELD_PREFIX = "$cay_faultResolved_";

    private Accessor faultResolvedFlagAccessor;

    EnhancedPojoPropertyFaultHandler(Class<?> objectClass, String propertyName) {
        this.faultResolvedFlagAccessor = new FieldAccessor(
                objectClass,
                FAULT_FIELD_PREFIX + propertyName,
                Boolean.TYPE);
    }
View Full Code Here

    static final String FAULT_FIELD_PREFIX = "$cay_faultResolved_";

    private Accessor faultResolvedFlagAccessor;

    EnhancedPojoPropertyFaultHandler(Class objectClass, String propertyName) {
        this.faultResolvedFlagAccessor = new FieldAccessor(
                objectClass,
                FAULT_FIELD_PREFIX + propertyName,
                Boolean.TYPE);
    }
View Full Code Here

import org.apache.cayenne.unit.util.TestBean;

public class FieldAccessorTest extends TestCase {

    public void testConstructor() {
        FieldAccessor accessor = new FieldAccessor(TestBean.class, "string", String.class);
        assertEquals("string", accessor.getName());
    }
View Full Code Here

        FieldAccessor accessor = new FieldAccessor(TestBean.class, "string", String.class);
        assertEquals("string", accessor.getName());
    }

    public void testGet() {
        FieldAccessor accessor = new FieldAccessor(TestBean.class, "string", String.class);

        TestBean object = new TestBean();
        object.setString("abc");
        assertEquals("abc", accessor.getValue(object));
    }
View Full Code Here

    public void testSetValue() {
        TestFields object = new TestFields();

        // string
        new FieldAccessor(TestFields.class, "stringField", String.class).setValue(
                object,
                "aaa");
        assertEquals("aaa", object.stringField);

        // primitive array
        byte[] bytes = new byte[] {
                1, 2, 3
        };
        new FieldAccessor(TestFields.class, "byteArrayField", byte[].class).setValue(
                object,
                bytes);
        assertSame(bytes, object.byteArrayField);

        // object array
        String[] strings = new String[] {
                "a", "b"
        };
        new FieldAccessor(TestFields.class, "stringArrayField", String[].class).setValue(
                object,
                strings);
        assertSame(strings, object.stringArrayField);
    }
View Full Code Here

    public void testSetValuePrimitive() {
        TestFields object = new TestFields();

        // primitive int .. write non-null
        new FieldAccessor(TestFields.class, "intField", Integer.TYPE).setValue(
                object,
                new Integer(6));
        assertEquals(6, object.intField);

        // primitive int .. write null
        object.intField = 55;
        new FieldAccessor(TestFields.class, "intField", Integer.TYPE).setValue(
                object,
                null);

        assertEquals(0, object.intField);
    }
View Full Code Here

TOP

Related Classes of org.apache.cayenne.reflect.FieldAccessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.