Make StringComparator deserialization case-insensitive (#3356)

This commit is contained in:
Jonathan Wei 2016-08-11 18:00:11 -07:00 committed by Fangjin Yang
parent 18af480017
commit 454587857c
2 changed files with 5 additions and 1 deletions

View File

@ -29,7 +29,7 @@ public abstract class StringComparator implements Comparator<String>
@JsonCreator
public static StringComparator fromString(String type)
{
switch (type) {
switch (type.toLowerCase()) {
case StringComparators.LEXICOGRAPHIC_NAME:
return StringComparators.LEXICOGRAPHIC;
case StringComparators.ALPHANUMERIC_NAME:

View File

@ -207,5 +207,9 @@ public class StringComparatorsTest
String makeFromJsonSpec = "\"numeric\"";
Assert.assertEquals(StringComparators.NUMERIC
, jsonMapper.readValue(makeFromJsonSpec, StringComparator.class));
makeFromJsonSpec = "\"NuMeRiC\"";
Assert.assertEquals(StringComparators.NUMERIC
, jsonMapper.readValue(makeFromJsonSpec, StringComparator.class));
}
}