Skip to content

Commit 0c9ed28

Browse files
committed
intermediate check-in to get things to compile; need to fix type id generation problems next
1 parent 2c20760 commit 0c9ed28

File tree

2 files changed

+18
-24
lines changed

2 files changed

+18
-24
lines changed

ion/src/main/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeResolverBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ public Class<?> getDefaultImpl() {
6060
* @param subtypes
6161
*/
6262
@Override
63-
public TypeSerializer buildTypeSerializer(SerializationConfig config, JavaType baseType, Collection<NamedType> subtypes) {
63+
public TypeSerializer buildTypeSerializer(SerializationConfig config, JavaType baseType,
64+
Collection<NamedType> subtypes) {
6465
return new IonAnnotationTypeSerializer(typeIdResolver);
6566
}
66-
67+
6768
/**
6869
* Creates a Jackson {@link TypeDeserializer}. Unlike type serializers, deserializers are responsible for
6970
* *all* steps of value deserialization: read type information, find the actual object deserializer, and run it.

ion/src/main/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeSerializer.java

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,46 +16,34 @@
1616

1717
import java.io.IOException;
1818

19-
import com.fasterxml.jackson.annotation.JsonTypeInfo;
19+
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
20+
2021
import com.fasterxml.jackson.core.JsonGenerationException;
2122
import com.fasterxml.jackson.core.JsonGenerator;
23+
import com.fasterxml.jackson.core.JsonToken;
2224
import com.fasterxml.jackson.databind.BeanProperty;
2325
import com.fasterxml.jackson.databind.jsontype.TypeIdResolver;
2426
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
27+
import com.fasterxml.jackson.databind.jsontype.impl.TypeSerializerBase;
2528
import com.fasterxml.jackson.dataformat.ion.IonGenerator;
2629

2730
/**
2831
* This is a {@link TypeSerializer} that places typing metadata in Ion type annotations. It requires that the underlying
2932
* {@link JsonGenerator} is actually a {@link com.fasterxml.jackson.dataformat.ion.IonGenerator}.
30-
*
33+
*<p>
3134
* Type serializers are responsible for handling the preamble and postamble of values, in addition to any possible
3235
* typing metadata (probably because type metadata can affect the pre/postamble content) -- in other words, once a
3336
* {@link TypeSerializer} gets involved, serializers skip normal pre/postambles and assume the TypeSerializer will do it
3437
* instead. This is why we have to do more than write type metadata in our writeTypePrefix/Suffix* implementations.
3538
*
3639
* @see MultipleTypeIdResolver
3740
*/
38-
public class IonAnnotationTypeSerializer extends TypeSerializer {
39-
40-
private final TypeIdResolver typeIdResolver;
41+
public class IonAnnotationTypeSerializer extends TypeSerializerBase
42+
{
43+
// private final TypeIdResolver typeIdResolver;
4144

4245
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);
5947
}
6048

6149
private IonGenerator ionGenerator(JsonGenerator g) throws JsonGenerationException {
@@ -65,6 +53,12 @@ private IonGenerator ionGenerator(JsonGenerator g) throws JsonGenerationExceptio
6553
throw new JsonGenerationException("Can only use IonTypeSerializer with IonGenerator", g);
6654
}
6755

56+
@Override
57+
public As getTypeInclusion() {
58+
// !!! 10-Jul-2017, tatu: Should vary appropriately, but...
59+
return As.PROPERTY;
60+
}
61+
6862
@Override
6963
public void writeTypePrefixForScalar(Object value, JsonGenerator g) throws IOException {
7064
}
@@ -112,7 +106,6 @@ public TypeSerializer forProperty(BeanProperty prop) {
112106
return this;
113107
}
114108

115-
116109
@Override
117110
public void writeCustomTypePrefixForScalar(Object value,
118111
JsonGenerator g, String typeId) throws IOException {

0 commit comments

Comments
 (0)