Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 960b539

Browse files
committed
Polishing.
See #3167
1 parent 8ef195f commit 960b539

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

‎src/main/java/org/springframework/data/util/KotlinBeanInfoFactory.java‎

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,27 @@ public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException {
6969
Collection<KCallable<?>> members = kotlinClass.getMembers();
7070
Map<String, PropertyDescriptor> descriptors = new LinkedHashMap<>(members.size(), 1.f);
7171

72+
collectKotlinProperties(beanClass, members, descriptors);
73+
collectBasicJavaProperties(beanClass, descriptors);
74+
75+
PropertyDescriptor[] propertyDescriptors = descriptors.values().toArray(new PropertyDescriptor[0]);
76+
77+
return new SimpleBeanInfo() {
78+
@Override
79+
public BeanDescriptor getBeanDescriptor() {
80+
return new BeanDescriptor(beanClass);
81+
}
82+
83+
@Override
84+
public PropertyDescriptor[] getPropertyDescriptors() {
85+
return propertyDescriptors;
86+
}
87+
};
88+
}
89+
90+
private static void collectKotlinProperties(Class<?> beanClass, Collection<KCallable<?>> members,
91+
Map<String, PropertyDescriptor> descriptors) throws IntrospectionException {
92+
7293
for (KCallable<?> member : members) {
7394

7495
if (member instanceof KProperty<?> property) {
@@ -100,6 +121,10 @@ public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException {
100121
descriptors.put(property.getName(), new PropertyDescriptor(property.getName(), getter, setter));
101122
}
102123
}
124+
}
125+
126+
private static void collectBasicJavaProperties(Class<?> beanClass, Map<String, PropertyDescriptor> descriptors)
127+
throws IntrospectionException {
103128

104129
Class<?> javaClass = beanClass;
105130
do {
@@ -123,20 +148,6 @@ public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException {
123148
descriptors.put(descriptor.getName(), descriptor);
124149
}
125150
}
126-
127-
PropertyDescriptor[] propertyDescriptors = descriptors.values().toArray(new PropertyDescriptor[0]);
128-
129-
return new SimpleBeanInfo() {
130-
@Override
131-
public BeanDescriptor getBeanDescriptor() {
132-
return new BeanDescriptor(beanClass);
133-
}
134-
135-
@Override
136-
public PropertyDescriptor[] getPropertyDescriptors() {
137-
return propertyDescriptors;
138-
}
139-
};
140151
}
141152

142153
@Nullable

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /