File tree 2 files changed +21
-1
lines changed
main/java/com/fasterxml/jackson/core/format
test/java/com/fasterxml/jackson/core/format
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ public MatchStrength getMatchStrength() {
91
91
*</pre>
92
92
*/
93
93
public String getMatchedFormatName () {
94
- return _match .getFormatName ();
94
+ return hasMatch () ? getMatch () .getFormatName () : null ;
95
95
}
96
96
97
97
/*
Original file line number Diff line number Diff line change @@ -35,4 +35,24 @@ public void testCreatesDataFormatMatcherTwo() throws IOException {
35
35
verifyException (e , "Illegal start/length" );
36
36
}
37
37
}
38
+
39
+ public void testGetMatchedFormatNameReturnsNameWhenMatches () {
40
+ DataFormatMatcher dataFormatMatcher = new DataFormatMatcher (null ,
41
+ new byte [2 ],
42
+ 1 ,
43
+ 0 ,
44
+ new JsonFactory (),
45
+ MatchStrength .SOLID_MATCH );
46
+ assertEquals (JsonFactory .FORMAT_NAME_JSON , dataFormatMatcher .getMatchedFormatName ());
47
+ }
48
+
49
+ public void testGetMatchedFormatNameReturnsNullWhenNoMatch () {
50
+ DataFormatMatcher dataFormatMatcher = new DataFormatMatcher (null ,
51
+ new byte [2 ],
52
+ 1 ,
53
+ 0 ,
54
+ null ,
55
+ MatchStrength .NO_MATCH );
56
+ assertNull (dataFormatMatcher .getMatchedFormatName ());
57
+ }
38
58
}
You can’t perform that action at this time.
0 commit comments