-
Notifications
You must be signed in to change notification settings - Fork 55
Closed
Labels
good first issueIssue that seems easy to resolve and is likely a good candidate for contributors new to projectIssue that seems easy to resolve and is likely a good candidate for contributors new to projectguava
Milestone
Description
This code doesn't work as expected
String json = "{\"lowerEndpoint\":1,\"lowerBoundType\":\"closed\",\"upperEndpoint\":2,\"upperBoundType\":\"closed\"}";
Range range = new ObjectMapper()
.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS)
.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_VALUES)
.readValue(json, Range.class);
This is because valueOf is being used, however it breaks concept of accepting case-insensitive enums above
private BoundType deserializeBoundType(DeserializationContext context, JsonParser p) throws IOException
{
expect(context, JsonToken.VALUE_STRING, p.getCurrentToken());
String name = p.getText();
try {
return BoundType.valueOf(name);
} catch (IllegalArgumentException e) {
return (BoundType) context.handleWeirdStringValue(BoundType.class, name,
"not a valid BoundType name (should be one oF: %s)",
Arrays.asList(BoundType.values()));
}
}
Fix is dead straightforward IMHO
MaksymTovstenko, bondars95 and NataDmitrieva
Metadata
Metadata
Assignees
Labels
good first issueIssue that seems easy to resolve and is likely a good candidate for contributors new to projectIssue that seems easy to resolve and is likely a good candidate for contributors new to projectguava