Skip to content

Commit ac416f8

Browse files
committed
Merge branch 'release/2.0.1'
2 parents 32d54e7 + 347ee6d commit ac416f8

File tree

3 files changed

+47
-11
lines changed

3 files changed

+47
-11
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ Allgemeine Bibliothek für BitCtrl-Projekte
77
## Version 2.0
88
- Update auf Java 8
99
- MessageHandler-Interface erweitert
10+
11+
## Version 2.0.1
12+
- AbstractBeanInfo prüft für Properties jetzt, ob es Getter und Setter gibt
13+

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.bitctrl</groupId>
77
<artifactId>com.bitctrl</artifactId>
8-
<version>2.0.0</version>
8+
<version>2.0.1</version>
99

1010
<name>Allgemeine BitCtrl-Bibliothek</name>
1111
<url>http://bitctrl.github.io/${project.artifactId}/</url>

src/main/java/com/bitctrl/beans/AbstractBeanInfo.java

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.beans.IntrospectionException;
3131
import java.beans.PropertyDescriptor;
3232
import java.beans.SimpleBeanInfo;
33+
import java.lang.reflect.Method;
3334
import java.util.Arrays;
3435
import java.util.List;
3536

@@ -94,23 +95,26 @@ public PropertyDescriptor[] getPropertyDescriptors() {
9495
synchronized (AbstractBeanInfo.class) {
9596
if (propertyDescriptorCache == null) {
9697
final PropertyInfo[] propInfo = getProperties();
97-
final List<PropertyInfo> hiddenProps = Arrays
98-
.asList(getHiddenProperties());
99-
final List<PropertyInfo> preferredProps = Arrays
100-
.asList(getPreferredProperties());
101-
final List<PropertyInfo> expertProps = Arrays
102-
.asList(getExpertProperties());
98+
final List<PropertyInfo> hiddenProps = Arrays.asList(getHiddenProperties());
99+
final List<PropertyInfo> preferredProps = Arrays.asList(getPreferredProperties());
100+
final List<PropertyInfo> expertProps = Arrays.asList(getExpertProperties());
103101
propertyDescriptorCache = new PropertyDescriptor[propInfo.length];
104102

105103
try {
106104
for (int i = 0; i < propertyDescriptorCache.length; ++i) {
107105
final PropertyDescriptor prop;
108106

109-
prop = new PropertyDescriptor(propInfo[i].name(),
110-
getBeanClass());
107+
Class<?> beanClass = getBeanClass();
108+
String propName = propInfo[i].name();
109+
propName = propName.substring(0, 1).toUpperCase() + propName.substring(1);
110+
111+
String readMethodName = getReadMethodName(beanClass, propName);
112+
String writeMethodName = getWriteMethodName(beanClass, propName);
113+
114+
prop = new PropertyDescriptor(propInfo[i].name(), getBeanClass(), readMethodName,
115+
writeMethodName);
111116
prop.setDisplayName(getDisplayName(propInfo[i]));
112-
prop
113-
.setShortDescription(getShortDescription(propInfo[i]));
117+
prop.setShortDescription(getShortDescription(propInfo[i]));
114118
if (hiddenProps.contains(propInfo[i])) {
115119
prop.setHidden(true);
116120
}
@@ -132,6 +136,34 @@ public PropertyDescriptor[] getPropertyDescriptors() {
132136
return propertyDescriptorCache;
133137
}
134138

139+
private String getReadMethodName(Class<?> beanClass, String propName) {
140+
141+
try {
142+
return beanClass.getMethod("get" + propName).getName();
143+
} catch (NoSuchMethodException ignored) {
144+
try {
145+
return beanClass.getMethod("is" + propName).getName();
146+
} catch (NoSuchMethodException ex) {
147+
return null;
148+
}
149+
}
150+
}
151+
152+
private String getWriteMethodName(Class<?> beanClass, String propName) {
153+
154+
String name = "set" + propName;
155+
156+
Method[] declaredMethods = beanClass.getDeclaredMethods();
157+
for ( Method method : declaredMethods) {
158+
if( name.equals(method.getName())) {
159+
return name;
160+
}
161+
}
162+
163+
return null;
164+
}
165+
166+
135167
/**
136168
* Gibt die Liste der Properties zurück der Java Bean zurück.
137169
*

0 commit comments

Comments
 (0)