@Override public AsWrapperTypeSerializer forProperty(BeanProperty prop) { return (_property == prop) ? this : new AsWrapperTypeSerializer(_idResolver, prop); }
@Override public void writeTypePrefixForScalar(Object value, JsonGenerator g) throws IOException { final String typeId = idFromValue(value); if (g.canWriteTypeId()) { if (typeId != null) { g.writeTypeId(typeId); } } else { // can still wrap ok g.writeStartObject(); g.writeFieldName(_validTypeId(typeId)); } }
@Override public void writeTypePrefixForArray(Object value, JsonGenerator jgen, Class<?> type) throws IOException { final String typeId = idFromValueAndType(value, type); if (jgen.canWriteTypeId()) { if (typeId != null) { jgen.writeTypeId(typeId); } jgen.writeStartArray(); } else { // can still wrap ok jgen.writeStartObject(); // and then JSON Array start caller wants jgen.writeArrayFieldStart(_validTypeId(typeId)); } }
@Override public void writeTypePrefixForArray(Object value, JsonGenerator jgen, Class<?> type) throws IOException, JsonProcessingException { // can still wrap ok jgen.writeStartObject(); // and then JSON Array start caller wants jgen.writeArrayFieldStart(idFromValueAndType(value, type)); }
@Override public void writeTypePrefixForScalar(Object value, JsonGenerator jgen) throws IOException, JsonProcessingException { // can still wrap ok jgen.writeStartObject(); jgen.writeFieldName(idFromValue(value)); }
public void writeCustomTypeSuffixForScalar(Object value, JsonGenerator jgen, String typeId) throws IOException, JsonProcessingException { writeTypeSuffixForScalar(value, jgen); // standard impl works fine } }
@Override public void writeCustomTypeSuffixForObject(Object value, JsonGenerator jgen, String typeId) throws IOException, JsonProcessingException { writeTypeSuffixForObject(value, jgen); // standard impl works fine }
@Override public void writeCustomTypeSuffixForArray(Object value, JsonGenerator jgen, String typeId) throws IOException, JsonProcessingException { writeTypeSuffixForArray(value, jgen); // standard impl works fine }
@Override public void writeCustomTypePrefixForArray(Object value, JsonGenerator g, String typeId) throws IOException { if (g.canWriteTypeId()) { if (typeId != null) { g.writeTypeId(typeId); } g.writeStartArray(); } else { g.writeStartObject(); g.writeArrayFieldStart(_validTypeId(typeId)); } }
@Override public void writeTypePrefixForScalar(Object value, JsonGenerator jgen) throws IOException { final String typeId = idFromValue(value); if (jgen.canWriteTypeId()) { if (typeId != null) { jgen.writeTypeId(typeId); } } else { // can still wrap ok jgen.writeStartObject(); jgen.writeFieldName(_validTypeId(typeId)); } }
@Override public void writeTypePrefixForScalar(Object value, JsonGenerator jgen, Class<?> type) throws IOException { final String typeId = idFromValueAndType(value, type); if (jgen.canWriteTypeId()) { if (typeId != null) { jgen.writeTypeId(typeId); } } else { // can still wrap ok jgen.writeStartObject(); jgen.writeFieldName(_validTypeId(typeId)); } }
@Override public void writeTypePrefixForScalar(Object value, JsonGenerator jgen, Class<?> type) throws IOException, JsonProcessingException { // can still wrap ok jgen.writeStartObject(); jgen.writeFieldName(idFromValueAndType(value, type)); }
@Override public void writeTypePrefixForArray(Object value, JsonGenerator jgen) throws IOException, JsonProcessingException { // can still wrap ok jgen.writeStartObject(); // and then JSON Array start caller wants jgen.writeArrayFieldStart(idFromValue(value)); }
@Override public void writeCustomTypeSuffixForScalar(Object value, JsonGenerator jgen, String typeId) throws IOException, JsonProcessingException { writeTypeSuffixForScalar(value, jgen); // standard impl works fine } }
public void writeCustomTypeSuffixForObject(Object value, JsonGenerator jgen, String typeId) throws IOException, JsonProcessingException { writeTypeSuffixForObject(value, jgen); // standard impl works fine }
public void writeCustomTypeSuffixForArray(Object value, JsonGenerator jgen, String typeId) throws IOException, JsonProcessingException { writeTypeSuffixForArray(value, jgen); // standard impl works fine }
@Override public void writeCustomTypePrefixForScalar(Object value, JsonGenerator jgen, String typeId) throws IOException { if (jgen.canWriteTypeId()) { if (typeId != null) { jgen.writeTypeId(typeId); } } else { jgen.writeStartObject(); jgen.writeFieldName(_validTypeId(typeId)); } }
@Override public TypeSerializer buildTypeSerializer(SerializationConfig config, JavaType baseType, Collection<NamedType> subtypes) { if (_idType == JsonTypeInfo.Id.NONE) { return null; } // 03-Oct-2016, tatu: As per [databind#1395] better prevent use for primitives, // regardless of setting if (baseType.isPrimitive()) { return null; } TypeIdResolver idRes = idResolver(config, baseType, subtypes, true, false); switch (_includeAs) { case WRAPPER_ARRAY: return new AsArrayTypeSerializer(idRes, null); case PROPERTY: return new AsPropertyTypeSerializer(idRes, null, _typeProperty); case WRAPPER_OBJECT: return new AsWrapperTypeSerializer(idRes, null); case EXTERNAL_PROPERTY: return new AsExternalTypeSerializer(idRes, null, _typeProperty); case EXISTING_PROPERTY: // as per [#528] return new AsExistingPropertyTypeSerializer(idRes, null, _typeProperty); } throw new IllegalStateException("Do not know how to construct standard type serializer for inclusion type: "+_includeAs); }
@Override public void writeTypePrefixForScalar(Object value, JsonGenerator jgen) throws IOException { final String typeId = idFromValue(value); if (jgen.canWriteTypeId()) { if (typeId != null) { jgen.writeTypeId(typeId); } } else { // can still wrap ok jgen.writeStartObject(); jgen.writeFieldName(_validTypeId(typeId)); } }
@Override public void writeTypePrefixForScalar(Object value, JsonGenerator jgen, Class<?> type) throws IOException { final String typeId = idFromValueAndType(value, type); if (jgen.canWriteTypeId()) { if (typeId != null) { jgen.writeTypeId(typeId); } } else { // can still wrap ok jgen.writeStartObject(); jgen.writeFieldName(_validTypeId(typeId)); } }