1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.beanutils.bugs.other;
18
19 import java.beans.BeanInfo;
20 import java.beans.IndexedPropertyDescriptor;
21 import java.beans.IntrospectionException;
22 import java.beans.Introspector;
23 import java.beans.PropertyDescriptor;
24 import java.util.ArrayList;
25 import java.util.List;
26
27
28
29
30
31
32
33
34 public class Jira492IndexedListsSupport {
35 public static class IndexedBean {
36 private List<String> someList = new ArrayList<String>();
37 public List<String> getSomeList() {
38 return someList;
39 }
40 public void setSomeList(List<String> someList) {
41 this.someList = someList;
42 }
43 public void setSomeList(int i, String value) {
44 someList.set(i, value);
45 }
46 public String getSomeList(int i) {
47 return someList.get(i);
48 }
49 }
50
51 public static boolean supportsIndexedLists() throws IntrospectionException {
52 BeanInfo beanInfo = Introspector.getBeanInfo(IndexedBean.class);
53 for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
54 if (pd.getName().equals("someList")) {
55 return pd instanceof IndexedPropertyDescriptor;
56 }
57 }
58 throw new IllegalStateException("Could not find PropertyDescriptor for 'file'");
59 }
60
61 }