16
16
17
17
import java .io .IOException ;
18
18
19
- import com .fasterxml .jackson .annotation .JsonTypeInfo ;
19
+ import com .fasterxml .jackson .annotation .JsonTypeInfo .As ;
20
+
20
21
import com .fasterxml .jackson .core .JsonGenerationException ;
21
22
import com .fasterxml .jackson .core .JsonGenerator ;
23
+ import com .fasterxml .jackson .core .JsonToken ;
22
24
import com .fasterxml .jackson .databind .BeanProperty ;
23
25
import com .fasterxml .jackson .databind .jsontype .TypeIdResolver ;
24
26
import com .fasterxml .jackson .databind .jsontype .TypeSerializer ;
27
+ import com .fasterxml .jackson .databind .jsontype .impl .TypeSerializerBase ;
25
28
import com .fasterxml .jackson .dataformat .ion .IonGenerator ;
26
29
27
30
/**
28
31
* This is a {@link TypeSerializer} that places typing metadata in Ion type annotations. It requires that the underlying
29
32
* {@link JsonGenerator} is actually a {@link com.fasterxml.jackson.dataformat.ion.IonGenerator}.
30
- *
33
+ *<p>
31
34
* Type serializers are responsible for handling the preamble and postamble of values, in addition to any possible
32
35
* typing metadata (probably because type metadata can affect the pre/postamble content) -- in other words, once a
33
36
* {@link TypeSerializer} gets involved, serializers skip normal pre/postambles and assume the TypeSerializer will do it
34
37
* instead. This is why we have to do more than write type metadata in our writeTypePrefix/Suffix* implementations.
35
38
*
36
39
* @see MultipleTypeIdResolver
37
40
*/
38
- public class IonAnnotationTypeSerializer extends TypeSerializer {
39
-
40
- private final TypeIdResolver typeIdResolver ;
41
+ public class IonAnnotationTypeSerializer extends TypeSerializerBase
42
+ {
43
+ // private final TypeIdResolver typeIdResolver;
41
44
42
45
IonAnnotationTypeSerializer (TypeIdResolver typeIdResolver ) {
43
- this .typeIdResolver = typeIdResolver ;
44
- }
45
-
46
- @ Override
47
- public JsonTypeInfo .As getTypeInclusion () {
48
- return null ;
49
- }
50
-
51
- @ Override
52
- public String getPropertyName () {
53
- return null ;
54
- }
55
-
56
- @ Override
57
- public TypeIdResolver getTypeIdResolver () {
58
- return typeIdResolver ;
46
+ super (typeIdResolver , null );
59
47
}
60
48
61
49
private IonGenerator ionGenerator (JsonGenerator g ) throws JsonGenerationException {
@@ -65,6 +53,12 @@ private IonGenerator ionGenerator(JsonGenerator g) throws JsonGenerationExceptio
65
53
throw new JsonGenerationException ("Can only use IonTypeSerializer with IonGenerator" , g );
66
54
}
67
55
56
+ @ Override
57
+ public As getTypeInclusion () {
58
+ // !!! 10-Jul-2017, tatu: Should vary appropriately, but...
59
+ return As .PROPERTY ;
60
+ }
61
+
68
62
@ Override
69
63
public void writeTypePrefixForScalar (Object value , JsonGenerator g ) throws IOException {
70
64
}
@@ -112,7 +106,6 @@ public TypeSerializer forProperty(BeanProperty prop) {
112
106
return this ;
113
107
}
114
108
115
-
116
109
@ Override
117
110
public void writeCustomTypePrefixForScalar (Object value ,
118
111
JsonGenerator g , String typeId ) throws IOException {
0 commit comments