Skip to content

Commit bf59bfb

Browse files
committed
More refactoring wrt #706
1 parent 52a49b8 commit bf59bfb

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

src/main/java/com/fasterxml/jackson/databind/jsonFormatVisitors/JsonFormatVisitorWrapper.java

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
import com.fasterxml.jackson.databind.JavaType;
44
import com.fasterxml.jackson.databind.JsonMappingException;
5+
import com.fasterxml.jackson.databind.SerializerProvider;
56

67
/**
78
* Interface for visitor callbacks, when type in question can be any of
89
* legal JSON types.
10+
*<p>
11+
* In most cases it will make more sense to extend {@link JsonFormatVisitorWrapper.Base}
12+
* instead of directly implementing this interface.
913
*/
1014
public interface JsonFormatVisitorWrapper extends JsonFormatVisitorWithSerializerProvider
1115
{
@@ -56,4 +60,86 @@ public interface JsonFormatVisitorWrapper extends JsonFormatVisitorWithSerialize
5660
* @since 2.2
5761
*/
5862
public JsonMapFormatVisitor expectMapFormat(JavaType type) throws JsonMappingException;
63+
64+
/**
65+
* Empty "no-op" implementation of {@link JsonFormatVisitorWrapper}, suitable for
66+
* sub-classing. Does implement {@link #setProvider(SerializerProvider)} and
67+
* {@link #getProvider()} as expected; other methods simply return null
68+
* and do nothing.
69+
*
70+
* @since 2.5
71+
*/
72+
public static class Base implements JsonFormatVisitorWrapper {
73+
protected SerializerProvider _provider;
74+
75+
public Base() { }
76+
77+
public Base(SerializerProvider p) {
78+
_provider = p;
79+
}
80+
81+
@Override
82+
public SerializerProvider getProvider() {
83+
return _provider;
84+
}
85+
86+
@Override
87+
public void setProvider(SerializerProvider p) {
88+
_provider = p;
89+
}
90+
91+
@Override
92+
public JsonObjectFormatVisitor expectObjectFormat(JavaType type)
93+
throws JsonMappingException {
94+
return null;
95+
}
96+
97+
@Override
98+
public JsonArrayFormatVisitor expectArrayFormat(JavaType type)
99+
throws JsonMappingException {
100+
return null;
101+
}
102+
103+
@Override
104+
public JsonStringFormatVisitor expectStringFormat(JavaType type)
105+
throws JsonMappingException {
106+
return null;
107+
}
108+
109+
@Override
110+
public JsonNumberFormatVisitor expectNumberFormat(JavaType type)
111+
throws JsonMappingException {
112+
return null;
113+
}
114+
115+
@Override
116+
public JsonIntegerFormatVisitor expectIntegerFormat(JavaType type)
117+
throws JsonMappingException {
118+
return null;
119+
}
120+
121+
@Override
122+
public JsonBooleanFormatVisitor expectBooleanFormat(JavaType type)
123+
throws JsonMappingException {
124+
return null;
125+
}
126+
127+
@Override
128+
public JsonNullFormatVisitor expectNullFormat(JavaType type)
129+
throws JsonMappingException {
130+
return null;
131+
}
132+
133+
@Override
134+
public JsonAnyFormatVisitor expectAnyFormat(JavaType type)
135+
throws JsonMappingException {
136+
return null;
137+
}
138+
139+
@Override
140+
public JsonMapFormatVisitor expectMapFormat(JavaType type)
141+
throws JsonMappingException {
142+
return null;
143+
}
144+
}
59145
}

0 commit comments

Comments
 (0)