Skip to content

Commit

Permalink
Minor tweak to #3305 impl
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Dec 11, 2021
1 parent 528c656 commit 86dd187
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -688,18 +688,19 @@ protected List<BeanPropertyWriter> filterBeanProperties(SerializationConfig conf
protected List<BeanPropertyWriter> filterUnwantedJDKProperties(SerializationConfig config,
BeanDescription beanDesc, List<BeanPropertyWriter> props)
{
// First, only consider something that implement `CharSequence`
// First, only consider something that implements `CharSequence`
if (beanDesc.getType().isTypeOrSubTypeOf(CharSequence.class)) {
Iterator<BeanPropertyWriter> it = props.iterator();
while (it.hasNext()) {
BeanPropertyWriter prop = it.next();
// And only has a single property from "isEmpty()" default method
if (props.size() == 1) {
BeanPropertyWriter prop = props.get(0);
// And only remove property induced by `isEmpty()` method declared
// in `CharSequence` (default implementation)
// (could in theory relax this limit, probably but... should be fine)
AnnotatedMember m = prop.getMember();
if ((m instanceof AnnotatedMethod)
&& "isEmpty".equals(m.getName())
&& m.getDeclaringClass() == CharSequence.class) {
it.remove();
props.remove(0);
}
}
}
Expand Down

0 comments on commit 86dd187

Please sign in to comment.