2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
 
   6  * ================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
 
   8  * you may not use this file except in compliance with the License.
 
   9  * You may obtain a copy of the License at
 
  11  *      http://www.apache.org/licenses/LICENSE-2.0
 
  13  * Unless required by applicable law or agreed to in writing, software
 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  * See the License for the specific language governing permissions and
 
  17  * limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.ccsdk.sli.plugins.yangserializers;
 
  26  * Abstraction of an entity which helps the data format serializers to obtain
 
  27  * schema context details and to build properties from data.
 
  29  * @param <T> type of schema node
 
  31 public abstract class SerializerHelper<T> {
 
  34     private String rootURI;
 
  36     protected SerializerHelper(T t, String uri) {
 
  41      * Returns root schema context node.
 
  43      * @return root schema context node
 
  45     protected abstract T getRootContext();
 
  48      * Returns current schema context node.
 
  50      * @return current schema context node
 
  52     protected abstract T getCurContext();
 
  55      * Returns child schema context node.
 
  57      * @return child schema context node
 
  59     protected abstract T getChildContext(T t, String name, String namespace);
 
  62      * Returns type of node
 
  66     protected abstract NodeType getNodeType(T t);
 
  69      * Adds a node to current tree.
 
  71      * @param name name of node
 
  72      * @param namespace namespace of node, it can be either module name or
 
  73      * namespace, null indicates parent namespace
 
  74      * @param value value of node, in case it's leaf/leaf-list node
 
  75      * @param valNamespace value namespace for identityref, could be module
 
  77      * @param type type of node if known like in case of JSON
 
  79     protected abstract void addNode(String name, String namespace, String value,
 
  80         String valNamespace, NodeType type);
 
  83      * Exits the node, in case if it's leaf node add to properties map.
 
  85     protected abstract void exitNode();
 
  88      * Returns the properties built corresponding to data.
 
  90      * @return properties map
 
  92     protected abstract Map<String, String> getProperties();