public class NumberSerializer extends StdScalarSerializer<java.lang.Number> implements ContextualSerializer
Number
s: both custom types and "big" numbers
like BigInteger
and BigDecimal
.JsonSerializer.None
Modifier and Type | Field and Description |
---|---|
static NumberSerializer |
instance
Static instance that is only to be used for
Number . |
Constructor and Description |
---|
NumberSerializer(java.lang.Class<? extends java.lang.Number> rawType) |
Modifier and Type | Method and Description |
---|---|
void |
acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor,
JavaType typeHint)
Default implementation specifies no format.
|
JsonSerializer<?> |
createContextual(SerializerProvider prov,
BeanProperty property)
Method called to see if a different (or differently configured) serializer
is needed to serialize values of specified property.
|
JsonNode |
getSchema(SerializerProvider provider,
java.lang.reflect.Type typeHint)
Default implementation simply claims type is "string"; usually
overriden by custom serializers.
|
void |
serialize(java.lang.Number value,
JsonGenerator g,
SerializerProvider provider)
Method that can be called to ask implementation to serialize
values of type this serializer handles.
|
serializeWithType
getSchema, handledType, wrapAndThrow, wrapAndThrow
getDelegatee, isEmpty, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, unwrappingSerializer, usesObjectId, withFilterId
public static final NumberSerializer instance
Number
.public NumberSerializer(java.lang.Class<? extends java.lang.Number> rawType)
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException
ContextualSerializer
createContextual
in interface ContextualSerializer
prov
- Serializer provider to use for accessing config, other serializersproperty
- Method or field that represents the property
(and is used to access value to serialize).
Should be available; but there may be cases where caller cannot provide it and
null is passed instead (in which case impls usually pass 'this' serializer as is)JsonMappingException
public void serialize(java.lang.Number value, JsonGenerator g, SerializerProvider provider) throws java.io.IOException
JsonSerializer
serialize
in class StdSerializer<java.lang.Number>
value
- Value to serialize; can not be null.g
- Generator used to output resulting Json contentprovider
- Provider that can be used to get serializers for
serializing Objects value contains, if any.java.io.IOException
public JsonNode getSchema(SerializerProvider provider, java.lang.reflect.Type typeHint)
StdSerializer
getSchema
in interface SchemaAware
getSchema
in class StdScalarSerializer<java.lang.Number>
provider
- The serializer provider.typeHint
- A hint about the type.public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
StdSerializer
acceptJsonFormatVisitor
in interface JsonFormatVisitable
acceptJsonFormatVisitor
in class StdScalarSerializer<java.lang.Number>
typeHint
- Type of element (entity like property) being visitedJsonMappingException
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"