Class JsonNodeConverter

java.lang.Object
io.lighty.codecs.util.JsonNodeConverter
All Implemented Interfaces:
NodeConverter

public class JsonNodeConverter extends Object implements NodeConverter
The implementation of NodeConverter which serializes and deserializes binding independent representation into/from JSON representation.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    JsonNodeConverter(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext)
    This constructor will create an instance of JsonNodeConverter with the given EffectiveModelContext.
    JsonNodeConverter(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier jsonCodecFactorySupplier)
    This constructor will create an instance of JsonNodeConverter with the given EffectiveModelContext and customizable JSONCodecFactorySupplier.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode
    deserialize(org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference inference, Reader inputData)
    Deserializes a given JSON input data into NormalizedNode.
    org.opendaylight.yangtools.yang.model.api.EffectiveModelContext
     
    serializeData(org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference inference, org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode normalizedNode)
    Serializes the given NormalizedNode into its Writer representation.
    serializeRpc(org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference inference, org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode normalizedNode)
    Serializes the input/output NormalizedNode of a RPC into its string representation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JsonNodeConverter

      public JsonNodeConverter(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext)
      This constructor will create an instance of JsonNodeConverter with the given EffectiveModelContext.

      The effective model context will be used for proper RPC and Node resolution.

      The JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02 will 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 of JsonNodeConverter with the given EffectiveModelContext and customizable JSONCodecFactorySupplier.

      The effective model context will be used for proper RPC and Node resolution.

      The JSONCodecFactorySupplier instance will be used for JSON serialization/deserialization of data.

      Parameters:
      effectiveModelContext - initial effective model context
      jsonCodecFactorySupplier - 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 given NormalizedNode into its Writer representation.
      Specified by:
      serializeData in interface NodeConverter
      Parameters:
      inference - SchemaInferenceStack.Inference pointing to normalizedNode's parent
      normalizedNode - 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: NodeConverter
      Serializes the input/output NormalizedNode of a RPC into its string representation.
      Specified by:
      serializeRpc in interface NodeConverter
      Parameters:
      inference - SchemaInferenceStack.Inference of input/output container of the RPC
      normalizedNode - 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 into NormalizedNode.
      Specified by:
      deserialize in interface NodeConverter
      Parameters:
      inference - SchemaInferenceStack.Inference pointing to a parent of the node to deserialize
      inputData - 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:
      getModelContext in interface NodeConverter