Class ConverterUtils

java.lang.Object
io.lighty.codecs.util.ConverterUtils

public final class ConverterUtils extends Object
A utility class which may be helpful while manipulating with binding independent nodes.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Optional<org.opendaylight.yangtools.yang.common.QName>
    getRpcQName(String inputString)
    Create RPC QName.
    static Optional<org.opendaylight.yangtools.yang.common.QName>
    getRpcQName(org.opendaylight.netconf.api.xml.XmlElement xmlElement)
    This method extracts from the given XmlElement the name and namespace from the first element and creates a QName.
    static Optional<@NonNull org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode<?>>
    getSchemaNode(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, String namespace, String revision, String localName)
    Finds the DataSchemaContextNode for the given namespace, revision and local name in EffectiveModelContext.
    static Optional<@NonNull org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode<?>>
    getSchemaNode(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.common.QName qname)
    Finds the DataSchemaContextNode for the given QName in EffectiveModelContext.
    static Optional<@NonNull org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode<?>>
    getSchemaNode(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier yangInstanceIdentifier)
    Finds the DataSchemaContextNode for the given YangInstanceIdentifier in EffectiveModelContext.
    static Optional<? extends org.opendaylight.yangtools.yang.model.api.NotificationDefinition>
    loadNotification(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.common.QName notificationQname)
    Utility method to extract the SchemaNode for the given Notification.
    static Optional<? extends org.opendaylight.yangtools.yang.model.api.RpcDefinition>
    loadRpc(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.common.QName rpcQName)
    Returns the RpcDefinition from the given EffectiveModelContext and given QName.
    static org.opendaylight.netconf.api.xml.XmlElement
    rpcAsInput(org.opendaylight.netconf.api.xml.XmlElement inputXmlElement)
     
    static org.opendaylight.netconf.api.xml.XmlElement
    rpcAsInput(org.opendaylight.netconf.api.xml.XmlElement inputXmlElement, String namespace)
    Removes the first XML tag and replaces it with an <input> element.
    static org.opendaylight.netconf.api.xml.XmlElement
    rpcAsOutput(org.opendaylight.netconf.api.xml.XmlElement inputXmlElement)
    Calls the method rpcAsOutput(XmlElement, String) with an empty namespace.
    static org.opendaylight.netconf.api.xml.XmlElement
    rpcAsOutput(org.opendaylight.netconf.api.xml.XmlElement inputXmlElement, String namespace)
    Removes the first XML tag and replaces it with an <output> element.
    static org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference
    toInference(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier yangInstanceIdentifier, org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext)
    Converts provided YangInstanceIdentifier to SchemaInferenceStack.Inference.

    Methods inherited from class java.lang.Object

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

    • loadRpc

      public static Optional<? extends org.opendaylight.yangtools.yang.model.api.RpcDefinition> loadRpc(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.common.QName rpcQName)
      Returns the RpcDefinition from the given EffectiveModelContext and given QName. The QName of a rpc can be constructed via

      QName.create("http://netconfcentral.org/ns/toaster", "2009-11-20", "make-toast"); , where "make-toast" is the name of the RPC given in the yang model.

      If the given RPC was found in the EffectiveModelContext the RpcDefinition will be returned

      Parameters:
      effectiveModelContext - the effective model context used for the RPC resolution
      rpcQName - QName of the RPC
      Returns:
      Optional representation of the RpcDefinition
      See Also:
      • QName
    • loadNotification

      public static Optional<? extends org.opendaylight.yangtools.yang.model.api.NotificationDefinition> loadNotification(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.common.QName notificationQname)
      Utility method to extract the SchemaNode for the given Notification.
      Parameters:
      effectiveModelContext - to be used
      notificationQname - yang RPC name
      Returns:
      Optional of SchemaNode
    • getRpcQName

      public static Optional<org.opendaylight.yangtools.yang.common.QName> getRpcQName(org.opendaylight.netconf.api.xml.XmlElement xmlElement)
      This method extracts from the given XmlElement the name and namespace from the first element and creates a QName.
      Parameters:
      xmlElement - input data.
      Returns:
      QName for input data or empty.
    • getRpcQName

      public static Optional<org.opendaylight.yangtools.yang.common.QName> getRpcQName(String inputString)
      Create RPC QName.
      Parameters:
      inputString - RPC name
      Returns:
      QName for RPC name or empty.
      Throws:
      IllegalArgumentException - if there was a problem during parsing the XML document
      See Also:
    • rpcAsInput

      public static org.opendaylight.netconf.api.xml.XmlElement rpcAsInput(org.opendaylight.netconf.api.xml.XmlElement inputXmlElement)
    • rpcAsInput

      public static org.opendaylight.netconf.api.xml.XmlElement rpcAsInput(org.opendaylight.netconf.api.xml.XmlElement inputXmlElement, String namespace)
      Removes the first XML tag and replaces it with an <input> element. This method may be useful when converting the input of a rpc. The provided namespace will be used for the input tag document.
      Parameters:
      inputXmlElement - input xml data to wrap.
      namespace - namespace
      Returns:
      wrapped xml data.
    • rpcAsOutput

      public static org.opendaylight.netconf.api.xml.XmlElement rpcAsOutput(org.opendaylight.netconf.api.xml.XmlElement inputXmlElement)
      Calls the method rpcAsOutput(XmlElement, String) with an empty namespace.
      Parameters:
      inputXmlElement - input rpc element data.
      Returns:
      wrapped xml element.
      See Also:
    • rpcAsOutput

      public static org.opendaylight.netconf.api.xml.XmlElement rpcAsOutput(org.opendaylight.netconf.api.xml.XmlElement inputXmlElement, String namespace)
      Removes the first XML tag and replaces it with an <output> element. This method may be useful when the output rpc is created. The namespace will be used for the output tag.
      Parameters:
      inputXmlElement - input rpc element data.
      namespace - namespace
      Returns:
      wrapped xml element.
      See Also:
      • XmlUtil
    • getSchemaNode

      public static Optional<@NonNull org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode<?>> getSchemaNode(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.common.QName qname)
      Finds the DataSchemaContextNode for the given QName in EffectiveModelContext.

      Search is performed only on first level nodes of the modules, for recursive search, the YangInstanceIdentifier is needed, thus consider using getSchemaNode(EffectiveModelContext, YangInstanceIdentifier).

      Parameters:
      effectiveModelContext - model context to search
      qname - QName of node to search for
      Returns:
      optional found DataSchemaContextNode
    • getSchemaNode

      public static Optional<@NonNull org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode<?>> getSchemaNode(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier yangInstanceIdentifier)
      Finds the DataSchemaContextNode for the given YangInstanceIdentifier in EffectiveModelContext.
      Parameters:
      effectiveModelContext - model context to search
      yangInstanceIdentifier - YangInstanceIdentifier of the node to search for
      Returns:
      optional found DataSchemaContextNode
    • getSchemaNode

      public static Optional<@NonNull org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode<?>> getSchemaNode(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, String namespace, String revision, String localName)
      Finds the DataSchemaContextNode for the given namespace, revision and local name in EffectiveModelContext.

      Search is performed only on first level nodes of the modules, for recursive search, the YangInstanceIdentifier is needed, thus consider using getSchemaNode(EffectiveModelContext, YangInstanceIdentifier).

      Parameters:
      effectiveModelContext - model context to search
      namespace - QName module namespace of the node to search for
      revision - QName module revision of the node to search for
      localName - QName local name of the node to search for
      Returns:
      optional found DataSchemaContextNode
    • toInference

      public static org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference toInference(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier yangInstanceIdentifier, org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext)
      Converts provided YangInstanceIdentifier to SchemaInferenceStack.Inference.
      Parameters:
      yangInstanceIdentifier - yang instance identifier
      effectiveModelContext - current model context
      Returns:
      SchemaInferenceStack.Inference