Package io.lighty.codecs.util
Class JsonNodeConverter
java.lang.Object
io.lighty.codecs.util.JsonNodeConverter
- All Implemented Interfaces:
NodeConverter
The implementation of
NodeConverter which serializes and deserializes binding independent
representation into/from JSON representation.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionJsonNodeConverter(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext) This constructor will create an instance ofJsonNodeConverterwith the givenEffectiveModelContext.JsonNodeConverter(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier jsonCodecFactorySupplier) This constructor will create an instance ofJsonNodeConverterwith the givenEffectiveModelContextand customizableJSONCodecFactorySupplier. -
Method Summary
Modifier and TypeMethodDescriptionorg.opendaylight.yangtools.yang.data.api.schema.NormalizedNodedeserialize(org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference inference, Reader inputData) Deserializes a given JSON input data intoNormalizedNode.org.opendaylight.yangtools.yang.model.api.EffectiveModelContextserializeData(org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference inference, org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode normalizedNode) Serializes the givenNormalizedNodeinto itsWriterrepresentation.serializeRpc(org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference inference, org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode normalizedNode) Serializes the input/outputNormalizedNodeof a RPC into its string representation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.lighty.codecs.util.NodeConverter
deserialize, deserialize, deserialize, serializeData, serializeData, serializeData, serializeRpc, serializeRpc
-
Constructor Details
-
JsonNodeConverter
public JsonNodeConverter(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext) This constructor will create an instance ofJsonNodeConverterwith the givenEffectiveModelContext.The effective model context will be used for proper RPC and Node resolution.
The
JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02will be used for JSON serialization/deserialization of data.- Parameters:
effectiveModelContext- initial effective model context
-
JsonNodeConverter
public JsonNodeConverter(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier jsonCodecFactorySupplier) This constructor will create an instance ofJsonNodeConverterwith the givenEffectiveModelContextand customizableJSONCodecFactorySupplier.The effective model context will be used for proper RPC and Node resolution.
The
JSONCodecFactorySupplierinstance will be used for JSON serialization/deserialization of data.- Parameters:
effectiveModelContext- initial effective model contextjsonCodecFactorySupplier- JSON codec factory supplier
-
-
Method Details
-
serializeData
public Writer serializeData(org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference inference, org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode normalizedNode) throws SerializationException Serializes the givenNormalizedNodeinto itsWriterrepresentation.- Specified by:
serializeDatain interfaceNodeConverter- Parameters:
inference-SchemaInferenceStack.Inferencepointing to normalizedNode's parentnormalizedNode- normalized node to serialize- Returns:
Writer- Throws:
SerializationException- if something goes wrong with serialization
-
serializeRpc
public Writer serializeRpc(org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference inference, org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode normalizedNode) throws SerializationException Description copied from interface:NodeConverterSerializes the input/outputNormalizedNodeof a RPC into its string representation.- Specified by:
serializeRpcin interfaceNodeConverter- Parameters:
inference-SchemaInferenceStack.Inferenceof input/output container of the RPCnormalizedNode- normalized nodes to be serialized- Returns:
- string representation of the given nodes starting with input or output tag
- Throws:
SerializationException- thrown in case serialization fails.
-
deserialize
public org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode deserialize(org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference inference, Reader inputData) throws DeserializationException Deserializes a given JSON input data intoNormalizedNode.- Specified by:
deserializein interfaceNodeConverter- Parameters:
inference-SchemaInferenceStack.Inferencepointing to a parent of the node to deserializeinputData- Reader containing input JSON data describing node to deserialize- Returns:
- deserialized
NormalizedNode - Throws:
DeserializationException- is thrown in case of an error during deserialization
-
getModelContext
public org.opendaylight.yangtools.yang.model.api.EffectiveModelContext getModelContext()- Specified by:
getModelContextin interfaceNodeConverter
-