java.beans.IndexedPropertyDescriptor Java Examples

The following examples show how to use java.beans.IndexedPropertyDescriptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_MixedBooleanExtendClass6() throws Exception {
    BeanInfo info = Introspector
            .getBeanInfo(MixedBooleanExtendClass6.class);
    Method getter = MixedBooleanExtendClass6.class
            .getDeclaredMethod("isList");
    Method setter = MixedBooleanSimpleClass25.class.getDeclaredMethod(
            "setList", boolean.class);

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertFalse(pd instanceof IndexedPropertyDescriptor);
            assertEquals(getter, pd.getReadMethod());
            assertEquals(setter, pd.getWriteMethod());
            break;
        }
    }
}
 
Example #2
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_MixedBooleanExtendClass13() throws Exception {
    BeanInfo info = Introspector
            .getBeanInfo(MixedBooleanExtendClass13.class);
    Method getter = MixedBooleanSimpleClass42.class
            .getDeclaredMethod("isList");
    Method setter = MixedBooleanSimpleClass42.class.getDeclaredMethod(
            "setList", boolean.class);

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertFalse(pd instanceof IndexedPropertyDescriptor);
            assertEquals(getter, pd.getReadMethod());
            assertEquals(setter, pd.getWriteMethod());
        }
    }
}
 
Example #3
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_MixedSimpleClass13() throws Exception {
    BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass13.class);
    Method getter = MixedSimpleClass13.class.getDeclaredMethod("getList",
            int.class);
    Method setter = MixedSimpleClass13.class.getDeclaredMethod("setList",
            int.class, Object.class);

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertTrue(pd instanceof IndexedPropertyDescriptor);
            assertNull(pd.getReadMethod());
            assertNull(pd.getWriteMethod());
            assertEquals(getter, ((IndexedPropertyDescriptor) pd)
                    .getIndexedReadMethod());
            assertEquals(setter, ((IndexedPropertyDescriptor) pd)
                    .getIndexedWriteMethod());
        }
    }
}
 
Example #4
Source File: Test6976577.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Class<?> bt = Accessor.getBeanType();
    Class<?> lt = Accessor.getListenerType();

    // test PropertyDescriptor
    PropertyDescriptor pd = new PropertyDescriptor("boolean", bt);
    test(pd.getReadMethod());
    test(pd.getWriteMethod());

    // test IndexedPropertyDescriptor
    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor("indexed", bt);
    test(ipd.getReadMethod());
    test(ipd.getWriteMethod());
    test(ipd.getIndexedReadMethod());
    test(ipd.getIndexedWriteMethod());

    // test EventSetDescriptor
    EventSetDescriptor esd = new EventSetDescriptor(bt, "test", lt, "process");
    test(esd.getAddListenerMethod());
    test(esd.getRemoveListenerMethod());
    test(esd.getGetListenerMethod());
    test(esd.getListenerMethods());
}
 
Example #5
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_MixedSimpleClass54() throws Exception {
    BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass54.class);
    Method setter = MixedSimpleClass54.class.getMethod("setList",
            new Class<?>[] { int.class, boolean.class });
    assertEquals(2, beanInfo.getPropertyDescriptors().length);
    for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertNull(pd.getReadMethod());
            assertNull(pd.getWriteMethod());
            assertTrue(pd instanceof IndexedPropertyDescriptor);
            assertNull(((IndexedPropertyDescriptor) pd)
                    .getIndexedReadMethod());
            assertEquals(setter,
                    ((IndexedPropertyDescriptor) pd)
                            .getIndexedWriteMethod());
        }
    }
}
 
Example #6
Source File: Test8034164.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void test(Class<?> type, boolean read, boolean write, boolean readIndexed, boolean writeIndexed) {
    PropertyDescriptor pd = BeanUtils.findPropertyDescriptor(type, "size");
    if (pd != null) {
        test(type, "read", read, null != pd.getReadMethod());
        test(type, "write", write, null != pd.getWriteMethod());
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            test(type, "indexed read", readIndexed, null != ipd.getIndexedReadMethod());
            test(type, "indexed write", writeIndexed, null != ipd.getIndexedWriteMethod());
        } else if (readIndexed || writeIndexed) {
            error(type, "indexed property does not exist");
        }
    } else if (read || write || readIndexed || writeIndexed) {
        error(type, "property does not exist");
    }
}
 
Example #7
Source File: ExtendedBeanInfo.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Nullable
private PropertyDescriptor findExistingPropertyDescriptor(String propertyName, Class<?> propertyType) {
	for (PropertyDescriptor pd : this.propertyDescriptors) {
		final Class<?> candidateType;
		final String candidateName = pd.getName();
		if (pd instanceof IndexedPropertyDescriptor) {
			IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
			candidateType = ipd.getIndexedPropertyType();
			if (candidateName.equals(propertyName) &&
					(candidateType.equals(propertyType) || candidateType.equals(propertyType.getComponentType()))) {
				return pd;
			}
		}
		else {
			candidateType = pd.getPropertyType();
			if (candidateName.equals(propertyName) &&
					(candidateType.equals(propertyType) || propertyType.equals(candidateType.getComponentType()))) {
				return pd;
			}
		}
	}
	return null;
}
 
Example #8
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_MixedBooleanExtendClass10() throws Exception {
    BeanInfo info = Introspector
            .getBeanInfo(MixedBooleanExtendClass10.class);
    Method setter = MixedBooleanExtendClass10.class.getDeclaredMethod(
            "setList", int.class, boolean.class);

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertTrue(pd instanceof IndexedPropertyDescriptor);
            assertNull(pd.getReadMethod());
            assertNull(pd.getWriteMethod());
            assertNull(((IndexedPropertyDescriptor) pd)
                    .getIndexedReadMethod());
            assertEquals(setter, ((IndexedPropertyDescriptor) pd)
                    .getIndexedWriteMethod());
            break;
        }
    }
}
 
Example #9
Source File: ExtendedBeanInfo.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private PropertyDescriptor findExistingPropertyDescriptor(String propertyName, Class<?> propertyType) {
	for (PropertyDescriptor pd : this.propertyDescriptors) {
		final Class<?> candidateType;
		final String candidateName = pd.getName();
		if (pd instanceof IndexedPropertyDescriptor) {
			IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
			candidateType = ipd.getIndexedPropertyType();
			if (candidateName.equals(propertyName) &&
					(candidateType.equals(propertyType) || candidateType.equals(propertyType.getComponentType()))) {
				return pd;
			}
		}
		else {
			candidateType = pd.getPropertyType();
			if (candidateName.equals(propertyName) &&
					(candidateType.equals(propertyType) || propertyType.equals(candidateType.getComponentType()))) {
				return pd;
			}
		}
	}
	return null;
}
 
Example #10
Source File: IndexedPropertyDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testEquals_ReadMethod() throws SecurityException,
        NoSuchMethodException, IntrospectionException {
    String propertyName = "PropertyFour";
    Class<MockJavaBean> beanClass = MockJavaBean.class;

    Method readMethod = beanClass.getMethod("getPropertyFive",
            (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + propertyName,
            new Class[] { String[].class });
    Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
            new Class[] { Integer.TYPE });
    Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
            new Class[] { Integer.TYPE, String.class });

    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
            propertyName, readMethod, writeMethod, indexedReadMethod,
            indexedWriteMethod);

    IndexedPropertyDescriptor ipd2 = new IndexedPropertyDescriptor(
            propertyName, beanClass);

    assertFalse(ipd.equals(ipd2));
}
 
Example #11
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_MixedSimpleClass56() throws Exception {
    BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass56.class);
    Method getter = MixedSimpleClass56.class.getMethod("getList",
            new Class<?>[] { int.class });
    Method setter = MixedSimpleClass56.class.getMethod("setList",
            new Class<?>[] { int.class, boolean.class });
    assertEquals(2, beanInfo.getPropertyDescriptors().length);
    for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertNull(pd.getReadMethod());
            assertNull(pd.getWriteMethod());
            assertTrue(pd instanceof IndexedPropertyDescriptor);
            assertEquals(getter,
                    ((IndexedPropertyDescriptor) pd).getIndexedReadMethod());
            assertEquals(setter,
                    ((IndexedPropertyDescriptor) pd)
                            .getIndexedWriteMethod());
        }
    }
}
 
Example #12
Source File: ExtendedBeanInfo.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Nullable
private PropertyDescriptor findExistingPropertyDescriptor(String propertyName, Class<?> propertyType) {
	for (PropertyDescriptor pd : this.propertyDescriptors) {
		final Class<?> candidateType;
		final String candidateName = pd.getName();
		if (pd instanceof IndexedPropertyDescriptor) {
			IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
			candidateType = ipd.getIndexedPropertyType();
			if (candidateName.equals(propertyName) &&
					(candidateType.equals(propertyType) || candidateType.equals(propertyType.getComponentType()))) {
				return pd;
			}
		}
		else {
			candidateType = pd.getPropertyType();
			if (candidateName.equals(propertyName) &&
					(candidateType.equals(propertyType) || propertyType.equals(candidateType.getComponentType()))) {
				return pd;
			}
		}
	}
	return null;
}
 
Example #13
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_MixedSimpleClass34() throws Exception {
    BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass34.class);
    Method indexedGetter = MixedSimpleClass34.class.getDeclaredMethod(
            "getList", int.class);

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertTrue(pd instanceof IndexedPropertyDescriptor);
            assertNull(pd.getReadMethod());
            assertNull(pd.getWriteMethod());
            assertEquals(indexedGetter, ((IndexedPropertyDescriptor) pd)
                    .getIndexedReadMethod());
            assertNull(((IndexedPropertyDescriptor) pd)
                    .getIndexedWriteMethod());

        }
    }
}
 
Example #14
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_MixedBooleanSimpleClass15() throws Exception {
    BeanInfo info = Introspector
            .getBeanInfo(MixedBooleanSimpleClass15.class);
    Method getter = MixedBooleanSimpleClass15.class.getDeclaredMethod(
            "getList", int.class);
    Method setter = MixedBooleanSimpleClass15.class.getDeclaredMethod(
            "setList", int.class, boolean.class);

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertTrue(pd instanceof IndexedPropertyDescriptor);
            assertNull(pd.getReadMethod());
            assertNull(pd.getWriteMethod());
            assertEquals(getter, ((IndexedPropertyDescriptor) pd)
                    .getIndexedReadMethod());
            assertEquals(setter, ((IndexedPropertyDescriptor) pd)
                    .getIndexedWriteMethod());
        }
    }
}
 
Example #15
Source File: Test8034085.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void test(Class<?> type, boolean read, boolean write, boolean readIndexed, boolean writeIndexed) {
    PropertyDescriptor pd = BeanUtils.findPropertyDescriptor(type, "size");
    if (pd != null) {
        test(type, "read", read, null != pd.getReadMethod());
        test(type, "write", write, null != pd.getWriteMethod());
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            test(type, "indexed read", readIndexed, null != ipd.getIndexedReadMethod());
            test(type, "indexed write", writeIndexed, null != ipd.getIndexedWriteMethod());
        } else if (readIndexed || writeIndexed) {
            error(type, "indexed property does not exist");
        }
    } else if (read || write || readIndexed || writeIndexed) {
        error(type, "property does not exist");
    }
}
 
Example #16
Source File: IndexedPropertyDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testHashCode() throws Exception {
    String propertyName = "PropertyFour";
    Class<MockJavaBean> beanClass = MockJavaBean.class;

    Method readMethod = beanClass.getMethod("get" + propertyName,
            (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + propertyName,
            new Class[] { String[].class });
    Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
            new Class[] { Integer.TYPE });
    Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
            new Class[] { Integer.TYPE, String.class });

    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
            propertyName, readMethod, writeMethod, indexedReadMethod,
            indexedWriteMethod);

    IndexedPropertyDescriptor ipd2 = new IndexedPropertyDescriptor(
            propertyName, beanClass);

    assertEquals(ipd, ipd2);
    assertEquals(ipd.hashCode(), ipd2.hashCode());
}
 
Example #17
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_MixedExtendClass10() throws Exception {
    BeanInfo info = Introspector.getBeanInfo(MixedExtendClass10.class);
    Method setter = MixedExtendClass10.class.getDeclaredMethod("setList",
            int.class, Object.class);

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertTrue(pd instanceof IndexedPropertyDescriptor);
            assertNull(pd.getReadMethod());
            assertNull(pd.getWriteMethod());
            assertNull(((IndexedPropertyDescriptor) pd)
                    .getIndexedReadMethod());
            assertEquals(setter, ((IndexedPropertyDescriptor) pd)
                    .getIndexedWriteMethod());
            break;
        }
    }
}
 
Example #18
Source File: Test6976577.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Class<?> bt = Accessor.getBeanType();
    Class<?> lt = Accessor.getListenerType();

    // test PropertyDescriptor
    PropertyDescriptor pd = new PropertyDescriptor("boolean", bt);
    test(pd.getReadMethod());
    test(pd.getWriteMethod());

    // test IndexedPropertyDescriptor
    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor("indexed", bt);
    test(ipd.getReadMethod());
    test(ipd.getWriteMethod());
    test(ipd.getIndexedReadMethod());
    test(ipd.getIndexedWriteMethod());

    // test EventSetDescriptor
    EventSetDescriptor esd = new EventSetDescriptor(bt, "test", lt, "process");
    test(esd.getAddListenerMethod());
    test(esd.getRemoveListenerMethod());
    test(esd.getGetListenerMethod());
    test(esd.getListenerMethods());
}
 
Example #19
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_MixedBooleanSimpleClass11() throws Exception {
    BeanInfo info = Introspector
            .getBeanInfo(MixedBooleanSimpleClass11.class);
    Method setter = MixedBooleanSimpleClass11.class.getDeclaredMethod(
            "setList", int.class, boolean.class);

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertTrue(pd instanceof IndexedPropertyDescriptor);
            assertNull(pd.getReadMethod());
            assertNull(pd.getWriteMethod());
            assertNull(((IndexedPropertyDescriptor) pd)
                    .getIndexedReadMethod());
            assertEquals(setter, ((IndexedPropertyDescriptor) pd)
                    .getIndexedWriteMethod());
        }
    }
}
 
Example #20
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_MixedSimpleClass48() throws Exception {
    BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass48.class);
    Method getter = MixedSimpleClass48.class.getMethod("getList",
            new Class<?>[] { int.class });
    assertEquals(2, beanInfo.getPropertyDescriptors().length);
    for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertNull(pd.getReadMethod());
            assertNull(pd.getWriteMethod());
            assertTrue(pd instanceof IndexedPropertyDescriptor);
            assertEquals(getter,
                    ((IndexedPropertyDescriptor) pd).getIndexedReadMethod());
            assertNull(((IndexedPropertyDescriptor) pd)
                    .getIndexedWriteMethod());
        }
    }
}
 
Example #21
Source File: Test8034085.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static void test(Class<?> type, boolean read, boolean write, boolean readIndexed, boolean writeIndexed) {
    PropertyDescriptor pd = BeanUtils.findPropertyDescriptor(type, "size");
    if (pd != null) {
        test(type, "read", read, null != pd.getReadMethod());
        test(type, "write", write, null != pd.getWriteMethod());
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            test(type, "indexed read", readIndexed, null != ipd.getIndexedReadMethod());
            test(type, "indexed write", writeIndexed, null != ipd.getIndexedWriteMethod());
        } else if (readIndexed || writeIndexed) {
            error(type, "indexed property does not exist");
        }
    } else if (read || write || readIndexed || writeIndexed) {
        error(type, "property does not exist");
    }
}
 
Example #22
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_MixedSimpleClass50() throws Exception {
    BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass50.class);
    Method setter = MixedSimpleClass50.class.getMethod("setList",
            new Class<?>[] { int.class, boolean.class });
    assertEquals(2, beanInfo.getPropertyDescriptors().length);
    for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertNull(pd.getReadMethod());
            assertNull(pd.getWriteMethod());
            assertTrue(pd instanceof IndexedPropertyDescriptor);
            assertNull(((IndexedPropertyDescriptor) pd)
                    .getIndexedReadMethod());
            assertEquals(setter,
                    ((IndexedPropertyDescriptor) pd)
                            .getIndexedWriteMethod());
        }
    }
}
 
Example #23
Source File: Test4634390.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),
                    ipd.getReadMethod(),
                    ipd.getWriteMethod(),
                    ipd.getIndexedReadMethod(),
                    ipd.getIndexedWriteMethod());
        } else {
            return new PropertyDescriptor(
                    pd.getName(),
                    pd.getReadMethod(),
                    pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printStackTrace();
        return null;
    }
}
 
Example #24
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_MixedSimpleClass30() throws Exception {
    BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass30.class);
    Method indexedGetter = MixedSimpleClass30.class.getDeclaredMethod(
            "getList", int.class);

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertTrue(pd instanceof IndexedPropertyDescriptor);
            assertNull(pd.getReadMethod());
            assertNull(pd.getWriteMethod());
            assertEquals(indexedGetter, ((IndexedPropertyDescriptor) pd)
                    .getIndexedReadMethod());
            assertNull(((IndexedPropertyDescriptor) pd)
                    .getIndexedWriteMethod());

        }
    }
}
 
Example #25
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_MixedBooleanExtendClass3() throws Exception {
    BeanInfo info = Introspector
            .getBeanInfo(MixedBooleanExtendClass3.class);
    Method getter = MixedBooleanSimpleClass1.class
            .getDeclaredMethod("isList");
    Method setter = MixedBooleanExtendClass3.class.getDeclaredMethod(
            "setList", boolean.class);

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertFalse(pd instanceof IndexedPropertyDescriptor);
            assertEquals(getter, pd.getReadMethod());
            assertEquals(setter, pd.getWriteMethod());
            break;
        }
    }
}
 
Example #26
Source File: IndexedPropertyDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testIndexedPropertyDescriptorStringClassStringStringStringString_WriteMethodNull()
        throws IntrospectionException {
    String propertyName = "PropertyFour";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
            propertyName, beanClass, "get" + propertyName, null, "get"
                    + propertyName, "set" + propertyName);
    assertNotNull(ipd.getReadMethod());
    assertNull(ipd.getWriteMethod());
    assertEquals(String.class, ipd.getIndexedPropertyType());

    new IndexedPropertyDescriptor(
            propertyName, beanClass, "get" + propertyName, "set"+propertyName, "", "set" + propertyName);

    try{
        new IndexedPropertyDescriptor(
            propertyName, beanClass, "get" + propertyName, "set"+propertyName, "get" + propertyName, "");
    fail();
    }catch(Exception e){
    }
}
 
Example #27
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_MixedBooleanSimpleClass6() throws Exception {
    BeanInfo info = Introspector
            .getBeanInfo(MixedBooleanSimpleClass6.class);
    Method getter = MixedBooleanSimpleClass6.class
            .getDeclaredMethod("getList");
    Method setter = MixedBooleanSimpleClass6.class.getDeclaredMethod(
            "setList", boolean.class);

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertFalse(pd instanceof IndexedPropertyDescriptor);
            assertEquals(getter, pd.getReadMethod());
            assertEquals(setter, pd.getWriteMethod());
        }
    }
}
 
Example #28
Source File: Test8034085.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void test(Class<?> type, boolean read, boolean write, boolean readIndexed, boolean writeIndexed) {
    PropertyDescriptor pd = BeanUtils.findPropertyDescriptor(type, "size");
    if (pd != null) {
        test(type, "read", read, null != pd.getReadMethod());
        test(type, "write", write, null != pd.getWriteMethod());
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            test(type, "indexed read", readIndexed, null != ipd.getIndexedReadMethod());
            test(type, "indexed write", writeIndexed, null != ipd.getIndexedWriteMethod());
        } else if (readIndexed || writeIndexed) {
            error(type, "indexed property does not exist");
        }
    } else if (read || write || readIndexed || writeIndexed) {
        error(type, "property does not exist");
    }
}
 
Example #29
Source File: Test8034085.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static void test(Class<?> type, boolean read, boolean write, boolean readIndexed, boolean writeIndexed) {
    PropertyDescriptor pd = BeanUtils.findPropertyDescriptor(type, "size");
    if (pd != null) {
        test(type, "read", read, null != pd.getReadMethod());
        test(type, "write", write, null != pd.getWriteMethod());
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            test(type, "indexed read", readIndexed, null != ipd.getIndexedReadMethod());
            test(type, "indexed write", writeIndexed, null != ipd.getIndexedWriteMethod());
        } else if (readIndexed || writeIndexed) {
            error(type, "indexed property does not exist");
        }
    } else if (read || write || readIndexed || writeIndexed) {
        error(type, "property does not exist");
    }
}
 
Example #30
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_MixedSimpleClass23() throws Exception {
    BeanInfo info = Introspector.getBeanInfo(MixedSimpleClass23.class);
    Method setter = MixedSimpleClass23.class.getDeclaredMethod("setList",
            int.class, Object.class);

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertTrue(pd instanceof IndexedPropertyDescriptor);
            assertNull(pd.getReadMethod());
            assertNull(pd.getWriteMethod());
            assertNull(((IndexedPropertyDescriptor) pd)
                    .getIndexedReadMethod());
            assertEquals(setter, ((IndexedPropertyDescriptor) pd)
                    .getIndexedWriteMethod());
        }
    }
}