1 package com.fasterxml.jackson.databind.jsonFormatVisitors;
2 
3 import com.fasterxml.jackson.databind.JavaType;
4 import com.fasterxml.jackson.databind.JsonMappingException;
5 import com.fasterxml.jackson.databind.SerializerProvider;
6 
7 /**
8  * Interface for visitor callbacks, when type in question can be any of
9  * 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.
13  */
14 public interface JsonFormatVisitorWrapper extends JsonFormatVisitorWithSerializerProvider
15 {
16     /**
17      * @param type Declared type of visited property (or List element) in Java
18      */
expectObjectFormat(JavaType type)19     public JsonObjectFormatVisitor expectObjectFormat(JavaType type) throws JsonMappingException;
20 
21     /**
22      * @param type Declared type of visited property (or List element) in Java
23      */
expectArrayFormat(JavaType type)24     public JsonArrayFormatVisitor expectArrayFormat(JavaType type) throws JsonMappingException;
25 
26     /**
27      * @param type Declared type of visited property (or List element) in Java
28      */
expectStringFormat(JavaType type)29     public JsonStringFormatVisitor expectStringFormat(JavaType type) throws JsonMappingException;
30 
31     /**
32      * @param type Declared type of visited property (or List element) in Java
33      */
expectNumberFormat(JavaType type)34     public JsonNumberFormatVisitor expectNumberFormat(JavaType type) throws JsonMappingException;
35 
36     /**
37      * @param type Declared type of visited property (or List element) in Java
38      */
expectIntegerFormat(JavaType type)39     public JsonIntegerFormatVisitor expectIntegerFormat(JavaType type) throws JsonMappingException;
40 
41     /**
42      * @param type Declared type of visited property (or List element) in Java
43      */
expectBooleanFormat(JavaType type)44     public JsonBooleanFormatVisitor expectBooleanFormat(JavaType type) throws JsonMappingException;
45 
46     /**
47      * @param type Declared type of visited property (or List element) in Java
48      */
expectNullFormat(JavaType type)49     public JsonNullFormatVisitor expectNullFormat(JavaType type) throws JsonMappingException;
50 
51     /**
52      * @param type Declared type of visited property (or List element) in Java
53      */
expectAnyFormat(JavaType type)54     public JsonAnyFormatVisitor expectAnyFormat(JavaType type) throws JsonMappingException;
55 
56     /**
57      * Method called when type is of Java {@link java.util.Map} type, and will
58      * be serialized as a JSON Object.
59      *
60      * @since 2.2
61      */
expectMapFormat(JavaType type)62     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 
Base()75         public Base() { }
76 
Base(SerializerProvider p)77         public Base(SerializerProvider p) {
78             _provider = p;
79         }
80 
81         @Override
getProvider()82         public SerializerProvider getProvider() {
83             return _provider;
84         }
85 
86         @Override
setProvider(SerializerProvider p)87         public void setProvider(SerializerProvider p) {
88             _provider = p;
89         }
90 
91         @Override
expectObjectFormat(JavaType type)92         public JsonObjectFormatVisitor expectObjectFormat(JavaType type)
93                 throws JsonMappingException {
94             return null;
95         }
96 
97         @Override
expectArrayFormat(JavaType type)98         public JsonArrayFormatVisitor expectArrayFormat(JavaType type)
99                   throws JsonMappingException {
100             return null;
101         }
102 
103         @Override
expectStringFormat(JavaType type)104         public JsonStringFormatVisitor expectStringFormat(JavaType type)
105                 throws JsonMappingException {
106             return null;
107         }
108 
109         @Override
expectNumberFormat(JavaType type)110         public JsonNumberFormatVisitor expectNumberFormat(JavaType type)
111                 throws JsonMappingException {
112             return null;
113         }
114 
115         @Override
expectIntegerFormat(JavaType type)116         public JsonIntegerFormatVisitor expectIntegerFormat(JavaType type)
117                 throws JsonMappingException {
118             return null;
119         }
120 
121         @Override
expectBooleanFormat(JavaType type)122         public JsonBooleanFormatVisitor expectBooleanFormat(JavaType type)
123                 throws JsonMappingException {
124             return null;
125         }
126 
127         @Override
expectNullFormat(JavaType type)128         public JsonNullFormatVisitor expectNullFormat(JavaType type)
129                 throws JsonMappingException {
130             return null;
131         }
132 
133         @Override
expectAnyFormat(JavaType type)134         public JsonAnyFormatVisitor expectAnyFormat(JavaType type)
135                 throws JsonMappingException {
136             return null;
137         }
138 
139         @Override
expectMapFormat(JavaType type)140         public JsonMapFormatVisitor expectMapFormat(JavaType type)
141                 throws JsonMappingException {
142             return null;
143         }
144    }
145 }
146