Top Description Fields Constructors Methods
com.google.gson

public sealed Enum LongSerializationPolicy

extends Enum<LongSerializationPolicy>
Class Inheritance
Imports
com.google.gson.internal.bind.TypeAdapters

Defines the expected format for a long or Long type when it is serialized.
Authors
Inderjeet Singh, Joel Leitch
Since
1.3

Field Summary

Modifier and TypeField and Description
public static final LongSerializationPolicy
DEFAULT

This is the "default" serialization policy that will output a Long object as a JSON number.

public static final LongSerializationPolicy
STRING

Serializes a long value as a quoted string.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public abstract JsonElement

Returns:

the serialized version of value
serialize
(Long
the long value to be serialized into a JsonElement
value
)

Serialize this value using this serialization policy.

pack-priv abstract TypeAdapter<Number>
typeAdapter()

Returns the corresponding TypeAdapter for this serialization policy.

public static LongSerializationPolicy
public static LongSerializationPolicy[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

DEFAULTback to summary
public static final LongSerializationPolicy DEFAULT

This is the "default" serialization policy that will output a Long object as a JSON number. For example, assume an object has a long field named "f" then the serialized output would be: {"f":123}

A null value is serialized as JsonNull.

STRINGback to summary
public static final LongSerializationPolicy STRING

Serializes a long value as a quoted string. For example, assume an object has a long field named "f" then the serialized output would be: {"f":"123"}

A null value is serialized as JsonNull.

Constructor Detail

LongSerializationPolicyback to summary
private LongSerializationPolicy()

Method Detail

serializeback to summary
public abstract JsonElement serialize(Long value)

Serialize this value using this serialization policy.

Parameters
value:Long

the long value to be serialized into a JsonElement

Returns:JsonElement

the serialized version of value

typeAdapterback to summary
pack-priv abstract TypeAdapter<Number> typeAdapter()

Returns the corresponding TypeAdapter for this serialization policy.

valueOfback to summary
public static LongSerializationPolicy valueOf(String name)
valuesback to summary
public static LongSerializationPolicy[] values()