ReferenceType.
Implements most of functionality, only leaving couple of abstract
methods for sub-classes to implement.
| Modifier and Type | Field and Description |
|---|---|
| protected final JavaType | _referredType
Value type |
| protected final Object | _suppressableValue
Value that indicates suppression mechanism to use for values contained;
either "filter" (of which |
| protected final boolean | _suppressNulls
Flag that indicates what to do with `null` values, distinct from
handling of |
| protected final NameTransformer | _unwrapper
In case of unwrapping, need name transformer. |
| public static final Object |
| Access | Constructor and Description |
|---|---|
| public | ReferenceTypeSerializer(ReferenceType fullType, boolean staticTyping, TypeSerializer vts, ValueSerializer<Object> ser)
|
| protected | ReferenceTypeSerializer(ReferenceTypeSerializer<?> base, BeanProperty property, TypeSerializer vts, ValueSerializer<?> valueSer, NameTransformer unwrapper, Object suppressableValue, boolean suppressNulls)
|
| Modifier and Type | Method and Description |
|---|---|
| private final ValueSerializer | _findCachedSerializer(SerializationContext provider, Class<?> rawType)
Helper method that encapsulates logic of retrieving and caching required serializer. |
| private final ValueSerializer | |
| protected abstract Object | |
| protected abstract Object | |
| protected abstract boolean | |
| protected boolean | |
| public void | acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
Overrides tools. Implements tools. Default implementation specifies no format. |
| public ValueSerializer | createContextual(SerializationContext ctxt, BeanProperty property)
Overrides tools. Method called to see if a different (or differently configured) serializer is needed to serialize values of specified property (or, for root values, in which case `null` is passed). |
| public JavaType | |
| public boolean | isEmpty(SerializationContext provider, T value)
Overrides tools. Method called to check whether given serializable value is considered "empty" value (for purposes of suppressing serialization of empty values). |
| public boolean | isUnwrappingSerializer()
Overrides tools. Accessor for checking whether this serializer is an "unwrapping" serializer; this is necessary to know since it may also require caller to suppress writing of the leading property name. |
| public void | serialize(T ref, JsonGenerator g, SerializationContext provider)
Implements abstract tools. Method that can be called to ask implementation to serialize values of type this serializer handles. |
| public void | serializeWithType(T ref, JsonGenerator g, SerializationContext provider, TypeSerializer typeSer)
Overrides tools. Method that can be called to ask implementation to serialize values of type this serializer handles, using specified type serializer for embedding necessary type information. |
| public ValueSerializer | unwrappingSerializer(NameTransformer transformer)
Overrides tools. Method that will return serializer instance that produces "unwrapped" serialization, if applicable for type being serialized (which is the case for some serializers that produce JSON Objects as output). |
| public abstract ReferenceTypeSerializer | withContentInclusion(Object suppressableValue, boolean suppressNulls)
Mutant factory method called to create a differently constructed instance, specifically with different exclusion rules for contained value. |
| protected abstract ReferenceTypeSerializer | withResolved(BeanProperty prop, TypeSerializer vts, ValueSerializer<?> valueSer, NameTransformer unwrapper)
Mutant factory method called when changes are needed; should construct newly configured instance with new values as indicated. |
| _referredType | back to summary |
|---|---|
| protected final JavaType _referredType Value type | |
| _suppressableValue | back to summary |
|---|---|
| protected final Object _suppressableValue Value that indicates suppression mechanism to use for values contained;
either "filter" (of which | |
| _suppressNulls | back to summary |
|---|---|
| protected final boolean _suppressNulls Flag that indicates what to do with `null` values, distinct from
handling of | |
| _unwrapper | back to summary |
|---|---|
| protected final NameTransformer _unwrapper In case of unwrapping, need name transformer. | |
| MARKER_FOR_EMPTY | back to summary |
|---|---|
| public static final Object MARKER_FOR_EMPTY | |
| ReferenceTypeSerializer | back to summary |
|---|---|
| public ReferenceTypeSerializer(ReferenceType fullType, boolean staticTyping, TypeSerializer vts, ValueSerializer<Object> ser) | |
| ReferenceTypeSerializer | back to summary |
|---|---|
| protected ReferenceTypeSerializer(ReferenceTypeSerializer<?> base, BeanProperty property, TypeSerializer vts, ValueSerializer<?> valueSer, NameTransformer unwrapper, Object suppressableValue, boolean suppressNulls) | |
| _findCachedSerializer | back to summary |
|---|---|
| private final ValueSerializer Helper method that encapsulates logic of retrieving and caching required serializer. | |
| _findSerializer | back to summary |
|---|---|
| private final ValueSerializer | |
| _getReferenced | back to summary |
|---|---|
| protected abstract Object _getReferenced(T value) | |
| _getReferencedIfPresent | back to summary |
|---|---|
| protected abstract Object _getReferencedIfPresent(T value) | |
| _isValuePresent | back to summary |
|---|---|
| protected abstract boolean _isValuePresent(T value) Method called to see if there is a value present or not. Note that value itself may still be `null`, even if present, if referential type allows three states (absent, present-null, present-non-null); some only allow two (absent, present-non-null). | |
| _useStatic | back to summary |
|---|---|
| protected boolean _useStatic(SerializationContext serializers, BeanProperty property, JavaType referredType) | |
| acceptJsonFormatVisitor | back to summary |
|---|---|
| public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) Overrides tools. Implements tools. Doc from tools. Default implementation specifies no format. This behavior is usually overriden by custom serializers.
| |
| createContextual | back to summary |
|---|---|
| public ValueSerializer Overrides tools. Doc from tools. Method called to see if a different (or differently configured) serializer is needed to serialize values of specified property (or, for root values, in which case `null` is passed). Note that instance that this method is called on is typically shared one and as a result method should NOT modify this instance but rather construct and return a new instance. This instance should only be returned as-is, in case it is already suitable for use. Note that method is only called once per POJO property, and for the first usage as root value serializer; it is not called for every serialization, as doing that would have significant performance impact; most serializers cache contextual instances for future use.
| |
| getReferredType | back to summary |
|---|---|
| public JavaType getReferredType() | |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty(SerializationContext provider, T value) throws JacksonException Overrides tools. Doc from tools. Method called to check whether given serializable value is considered "empty" value (for purposes of suppressing serialization of empty values). Default implementation will consider only null values to be empty.
| |
| isUnwrappingSerializer | back to summary |
|---|---|
| public boolean isUnwrappingSerializer() Overrides tools. Doc from tools. Accessor for checking whether this serializer is an "unwrapping" serializer; this is necessary to know since it may also require caller to suppress writing of the leading property name.
| |
| serialize | back to summary |
|---|---|
| public void serialize(T ref, JsonGenerator g, SerializationContext provider) throws JacksonException Implements abstract tools. Doc from tools. Method that can be called to ask implementation to serialize values of type this serializer handles.
| |
| serializeWithType | back to summary |
|---|---|
| public void serializeWithType(T ref, JsonGenerator g, SerializationContext provider, TypeSerializer typeSer) throws JacksonException Overrides tools. Doc from tools. Method that can be called to ask implementation to serialize values of type this serializer handles, using specified type serializer for embedding necessary type information.
Default implementation will throw For simple datatypes written as a single scalar value (JSON String, Number, Boolean), implementation would look like: // note: method to call depends on whether this type is serialized as JSON scalar, object or Array! typeSer.writeTypePrefixForScalar(value, gen); serialize(value, gen, provider); typeSer.writeTypeSuffixForScalar(value, gen);and implementations for type serialized as JSON Arrays or Objects would differ slightly, as START-ARRAY/END-ARRAY and
START-OBJECT/END-OBJECT pairs
need to be properly handled with respect to serializing of contents.
| |
| unwrappingSerializer | back to summary |
|---|---|
| public ValueSerializer Overrides tools. Doc from tools. Method that will return serializer instance that produces "unwrapped" serialization, if applicable for type being serialized (which is the case for some serializers that produce JSON Objects as output). If no unwrapped serializer can be constructed, will simply return serializer as-is. Default implementation just returns serializer as-is, indicating that no unwrapped variant exists
| |
| withContentInclusion | back to summary |
|---|---|
| public abstract ReferenceTypeSerializer Mutant factory method called to create a differently constructed instance, specifically with different exclusion rules for contained value. Note caller has verified that there are changes, so implementations need NOT check if a new instance is needed. | |
| withResolved | back to summary |
|---|---|
| protected abstract ReferenceTypeSerializer Mutant factory method called when changes are needed; should construct newly configured instance with new values as indicated. Note caller has verified that there are changes, so implementations need NOT check if a new instance is needed. | |