java.lang.Object
org.eclipse.yasson.internal.ProcessingContext
org.eclipse.yasson.internal.SerializationContextImpl
- All Implemented Interfaces:
jakarta.json.bind.serializer.SerializationContext
public class SerializationContextImpl
extends ProcessingContext
implements jakarta.json.bind.serializer.SerializationContext
JSONB marshaller. Created each time marshalling operation called.
-
Constructor Summary
ConstructorDescriptionSerializationContextImpl
(JsonbContext jsonbContext) Creates Marshaller for generation to String.SerializationContextImpl
(JsonbContext jsonbContext, Type rootRuntimeType) Creates Marshaller for generation to String. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addProcessedObject
(Object object) Adds currently processed object to theSet
.getKey()
Current property key name.getRootSerializer
(Type type) boolean
Value from this property is only used inNullSerializer
.boolean
isRoot()
Serialized value is a root value.void
Marshals given object to provided Writer or OutputStream.void
Marshals given object to provided Writer or OutputStream.void
marshallWithoutClose
(Object object, jakarta.json.stream.JsonGenerator jsonGenerator) Marshals given object to provided Writer or OutputStream.boolean
removeProcessedObject
(Object object) Removes processed object from theSet
.<T> void
<T> void
serialize
(T object, jakarta.json.stream.JsonGenerator generator) <T> void
serializeObject
(T root, jakarta.json.stream.JsonGenerator generator) Serializes root element.void
setContainerWithNulls
(boolean writeNulls) Set if container supports null values.void
Set new current property key name.void
setRoot
(boolean root) Set whether serialized value is root value.Methods inherited from class org.eclipse.yasson.internal.ProcessingContext
getJsonbContext, getMappingContext
-
Constructor Details
-
SerializationContextImpl
Creates Marshaller for generation to String.- Parameters:
jsonbContext
- Current context.rootRuntimeType
- Type of root object.
-
SerializationContextImpl
Creates Marshaller for generation to String.- Parameters:
jsonbContext
- Current context.
-
-
Method Details
-
setKey
Set new current property key name.- Parameters:
key
- key name
-
getKey
Current property key name.- Returns:
- current property key name
-
isRoot
public boolean isRoot()Serialized value is a root value.- Returns:
- is root value
-
setRoot
public void setRoot(boolean root) Set whether serialized value is root value.- Parameters:
root
- is root value
-
isContainerWithNulls
public boolean isContainerWithNulls()Value from this property is only used inNullSerializer
. It should not be used anywhere else.- Returns:
- if container supports nulls
-
setContainerWithNulls
public void setContainerWithNulls(boolean writeNulls) Set if container supports null values.- Parameters:
writeNulls
- should write nulls in container
-
marshall
Marshals given object to provided Writer or OutputStream.- Parameters:
object
- object to marshalljsonGenerator
- generator to useclose
- if generator should be closed
-
marshall
Marshals given object to provided Writer or OutputStream. Closes the generator on completion.- Parameters:
object
- object to marshalljsonGenerator
- generator to use
-
marshallWithoutClose
Marshals given object to provided Writer or OutputStream. Leaves generator open for further interaction after completion.- Parameters:
object
- object to marshalljsonGenerator
- generator to use
-
serialize
- Specified by:
serialize
in interfacejakarta.json.bind.serializer.SerializationContext
-
serialize
public <T> void serialize(T object, jakarta.json.stream.JsonGenerator generator) - Specified by:
serialize
in interfacejakarta.json.bind.serializer.SerializationContext
-
serializeObject
public <T> void serializeObject(T root, jakarta.json.stream.JsonGenerator generator) Serializes root element.- Type Parameters:
T
- Root type- Parameters:
root
- Root.generator
- JSON generator.
-
getRootSerializer
-
addProcessedObject
Adds currently processed object to theSet
.- Overrides:
addProcessedObject
in classProcessingContext
- Parameters:
object
- processed object- Returns:
- if object was added
-
removeProcessedObject
Removes processed object from theSet
.- Overrides:
removeProcessedObject
in classProcessingContext
- Parameters:
object
- processed object- Returns:
- if object was removed
-