Rename PathArgumentTypes to LithiumPathArgument
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / stream / AbstractLithiumDataInput.java
index 05864cdda24859235c14d1d13be93bfaa9836294..e2637482653e516d4ebffd6f616cd1ca93bb91c8 100644 (file)
@@ -26,7 +26,6 @@ import java.util.Set;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.dom.DOMSource;
-import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory;
 import org.opendaylight.yangtools.util.ImmutableOffsetMapTemplate;
 import org.opendaylight.yangtools.yang.common.Empty;
@@ -38,7 +37,6 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Element;
@@ -50,23 +48,16 @@ import org.xml.sax.SAXException;
  * nodes. This process goes in recursive manner, where each NodeTypes object signifies the start of the object, except
  * END_NODE. If a node can have children, then that node's end is calculated based on appearance of END_NODE.
  */
-abstract class AbstractLithiumDataInput extends ForwardingDataInput implements NormalizedNodeDataInput {
+abstract class AbstractLithiumDataInput extends AbstractNormalizedNodeDataInput {
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractLithiumDataInput.class);
 
-    private final @NonNull DataInput input;
-
     private final List<String> codedStringMap = new ArrayList<>();
 
     private QName lastLeafSetQName;
 
     AbstractLithiumDataInput(final DataInput input) {
-        this.input = requireNonNull(input);
-    }
-
-    @Override
-    final DataInput delegate() {
-        return input;
+        super(input);
     }
 
     @Override
@@ -76,43 +67,43 @@ abstract class AbstractLithiumDataInput extends ForwardingDataInput implements N
 
     private void streamNormalizedNode(final NormalizedNodeStreamWriter writer, final byte nodeType) throws IOException {
         switch (nodeType) {
-            case NodeTypes.ANY_XML_NODE:
+            case LithiumNode.ANY_XML_NODE:
                 streamAnyxml(writer);
                 break;
-            case NodeTypes.AUGMENTATION_NODE:
+            case LithiumNode.AUGMENTATION_NODE:
                 streamAugmentation(writer);
                 break;
-            case NodeTypes.CHOICE_NODE:
+            case LithiumNode.CHOICE_NODE:
                 streamChoice(writer);
                 break;
-            case NodeTypes.CONTAINER_NODE:
+            case LithiumNode.CONTAINER_NODE:
                 streamContainer(writer);
                 break;
-            case NodeTypes.LEAF_NODE:
+            case LithiumNode.LEAF_NODE:
                 streamLeaf(writer);
                 break;
-            case NodeTypes.LEAF_SET:
+            case LithiumNode.LEAF_SET:
                 streamLeafSet(writer);
                 break;
-            case NodeTypes.ORDERED_LEAF_SET:
+            case LithiumNode.ORDERED_LEAF_SET:
                 streamOrderedLeafSet(writer);
                 break;
-            case NodeTypes.LEAF_SET_ENTRY_NODE:
+            case LithiumNode.LEAF_SET_ENTRY_NODE:
                 streamLeafSetEntry(writer);
                 break;
-            case NodeTypes.MAP_ENTRY_NODE:
+            case LithiumNode.MAP_ENTRY_NODE:
                 streamMapEntry(writer);
                 break;
-            case NodeTypes.MAP_NODE:
+            case LithiumNode.MAP_NODE:
                 streamMap(writer);
                 break;
-            case NodeTypes.ORDERED_MAP_NODE:
+            case LithiumNode.ORDERED_MAP_NODE:
                 streamOrderedMap(writer);
                 break;
-            case NodeTypes.UNKEYED_LIST:
+            case LithiumNode.UNKEYED_LIST:
                 streamUnkeyedList(writer);
                 break;
-            case NodeTypes.UNKEYED_LIST_ITEM:
+            case LithiumNode.UNKEYED_LIST_ITEM:
                 streamUnkeyedListItem(writer);
                 break;
             default:
@@ -230,8 +221,8 @@ abstract class AbstractLithiumDataInput extends ForwardingDataInput implements N
         writer.startMapEntryNode(entryIdentifier, NormalizedNodeStreamWriter.UNKNOWN_SIZE);
 
         // Same loop as commonStreamContainer(), but ...
-        for (byte nodeType = input.readByte(); nodeType != NodeTypes.END_NODE; nodeType = input.readByte()) {
-            if (nodeType == NodeTypes.LEAF_NODE) {
+        for (byte nodeType = input.readByte(); nodeType != LithiumNode.END_NODE; nodeType = input.readByte()) {
+            if (nodeType == LithiumNode.LEAF_NODE) {
                 // ... leaf nodes may need de-duplication
                 streamLeaf(writer, entryIdentifier);
             } else {
@@ -256,7 +247,7 @@ abstract class AbstractLithiumDataInput extends ForwardingDataInput implements N
     }
 
     private void commonStreamContainer(final NormalizedNodeStreamWriter writer) throws IOException {
-        for (byte nodeType = input.readByte(); nodeType != NodeTypes.END_NODE; nodeType = input.readByte()) {
+        for (byte nodeType = input.readByte(); nodeType != LithiumNode.END_NODE; nodeType = input.readByte()) {
             streamNormalizedNode(writer, nodeType);
         }
         writer.endNode();
@@ -287,16 +278,16 @@ abstract class AbstractLithiumDataInput extends ForwardingDataInput implements N
     final String readCodedString() throws IOException {
         final byte valueType = input.readByte();
         switch (valueType) {
-            case TokenTypes.IS_NULL_VALUE:
+            case LithiumTokens.IS_NULL_VALUE:
                 return null;
-            case TokenTypes.IS_CODE_VALUE:
+            case LithiumTokens.IS_CODE_VALUE:
                 final int code = input.readInt();
                 try {
                     return codedStringMap.get(code);
                 } catch (IndexOutOfBoundsException e) {
                     throw new IOException("String code " + code + " was not found", e);
                 }
-            case TokenTypes.IS_STRING_VALUE:
+            case LithiumTokens.IS_STRING_VALUE:
                 final String value = input.readUTF().intern();
                 codedStringMap.add(value);
                 return value;
@@ -409,18 +400,6 @@ abstract class AbstractLithiumDataInput extends ForwardingDataInput implements N
         return new String(bytes, StandardCharsets.UTF_8);
     }
 
-    @Override
-    public final SchemaPath readSchemaPath() throws IOException {
-        final boolean absolute = input.readBoolean();
-        final int size = input.readInt();
-
-        final Builder<QName> qnames = ImmutableList.builderWithExpectedSize(size);
-        for (int i = 0; i < size; ++i) {
-            qnames.add(readQName());
-        }
-        return SchemaPath.create(qnames.build(), absolute);
-    }
-
     @Override
     public final YangInstanceIdentifier readYangInstanceIdentifier() throws IOException {
         return readYangInstanceIdentifierInternal();
@@ -450,13 +429,13 @@ abstract class AbstractLithiumDataInput extends ForwardingDataInput implements N
         int type = input.readByte();
 
         switch (type) {
-            case PathArgumentTypes.AUGMENTATION_IDENTIFIER:
+            case LithiumPathArgument.AUGMENTATION_IDENTIFIER:
                 return readAugmentationIdentifier();
-            case PathArgumentTypes.NODE_IDENTIFIER:
+            case LithiumPathArgument.NODE_IDENTIFIER:
                 return readNodeIdentifier();
-            case PathArgumentTypes.NODE_IDENTIFIER_WITH_PREDICATES:
+            case LithiumPathArgument.NODE_IDENTIFIER_WITH_PREDICATES:
                 return readNormalizedNodeWithPredicates();
-            case PathArgumentTypes.NODE_IDENTIFIER_WITH_VALUE:
+            case LithiumPathArgument.NODE_IDENTIFIER_WITH_VALUE:
                 return new NodeWithValue<>(readQName(), readObject());
             default:
                 // FIXME: throw hard error