Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -403,18 +403,18 @@ protected void collectAll()
property.mergeAnnotations(_forSerialization);
}

// And use custom naming strategy, if applicable...
PropertyNamingStrategy naming = _findNamingStrategy();
if (naming != null) {
_renameUsing(props, naming);
}

// Sort by visibility (explicit over implicit); drop all but first of member
// type (getter, setter etc) if there is visibility difference
for (POJOPropertyBuilder property : props.values()) {
property.trimByVisibility();
}

// And use custom naming strategy, if applicable...
PropertyNamingStrategy naming = _findNamingStrategy();
if (naming != null) {
_renameUsing(props, naming);
}

// and, if required, apply wrapper name: note, MUST be done after
// annotations are merged.
if (_config.isEnabled(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,15 @@ public DuplicateGetterCreatorBean(@JsonProperty("bloop") @A boolean bloop) {}
public boolean getBloop() { return true; }
}

static class DuplicateSetterBean {
public void setBloop(Boolean bloop) {
}

@JsonSetter
public void setBloop(Object bloop) {
}
}

/*
/**********************************************************
/* Unit tests
Expand Down Expand Up @@ -493,6 +502,26 @@ public void testDuplicateGettersCreator() throws Exception
assertTrue(prop._getters.next.value.hasAnnotation(A.class));
}

public void testDuplicateSetters() throws Exception {
POJOPropertiesCollector coll = collector(MAPPER, DuplicateSetterBean.class, true);
List<BeanPropertyDefinition> props = coll.getProperties();
assertEquals(1, props.size());
BeanPropertyDefinition prop = props.get(0);
assertEquals("bloop", prop.getName());
assertEquals(prop.getSetter().getRawParameterType(0), Object.class);
}

public void testDuplicateSettersHaveCustomNamingStrategy() throws Exception {
ObjectMapper mapper = newJsonMapper();
mapper.setPropertyNamingStrategy(PropertyNamingStrategies.LOWER_CAMEL_CASE);
POJOPropertiesCollector coll = collector(mapper, DuplicateSetterBean.class, false);
List<BeanPropertyDefinition> props = coll.getProperties();
assertEquals(1, props.size());
BeanPropertyDefinition prop = props.get(0);
assertEquals("bloop", prop.getName());
assertEquals(prop.getSetter().getRawParameterType(0), Object.class);
}

private void _verifyProperty(BeanDescription beanDesc,
boolean verifyDesc, boolean verifyIndex, String expDefaultValue)
{
Expand Down