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 @JsonCreator
public static StringComparator fromString(String type) public static StringComparator fromString(String type)
{ {
switch (type) { switch (type.toLowerCase()) {
case StringComparators.LEXICOGRAPHIC_NAME: case StringComparators.LEXICOGRAPHIC_NAME:
return StringComparators.LEXICOGRAPHIC; return StringComparators.LEXICOGRAPHIC;
case StringComparators.ALPHANUMERIC_NAME: case StringComparators.ALPHANUMERIC_NAME:

View File

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