Define AnyxmlNode and ForeignDataNode 17/81217/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 27 Mar 2019 09:25:41 +0000 (10:25 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 27 Mar 2019 09:28:42 +0000 (10:28 +0100)
ForeignDataNode is a NormalizedNode anchor pointing towards values
in foreign object models. A prime example is AnyXmlNode, which holds
a value in DOMSource object model.

Since anyxml data can potentially be held in multitude of formats,
define AnyxmlNode which binds ForeignDataNode as a holder of anyxml
value, but does not further specify object model in use.

Finally AnyXmlNode is refactored to be a DOMSource specialization
of AnyxmlNode.

JIRA: YANGTOOLS-975
Change-Id: I1a5476525d711e3e782ed5f8a0691a9fa51f827f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/AnyXmlNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/AnyxmlNode.java [new file with mode: 0644]
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/ForeignDataNode.java [new file with mode: 0644]

index 67cf13d64f07fee2aaa212424ce5f26e6441ed71..2d57775580e2da9067c993dc4f4abf4329f6a1f0 100644 (file)
@@ -9,12 +9,17 @@ package org.opendaylight.yangtools.yang.data.api.schema;
 
 import javax.xml.transform.dom.DOMSource;
 import org.opendaylight.yangtools.yang.data.api.AttributesContainer;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 
 /**
- * AN normalizedNode.
+ * An AnyxmlNode with data in {@link DOMSource} format.
  */
-public interface AnyXmlNode extends AttributesContainer, DataContainerChild<NodeIdentifier, DOMSource> {
+// FIXME: 4.0.0: YANGTOOLS-976: rename to DOMSourceAnyxmlNode
+public interface AnyXmlNode extends AttributesContainer, AnyxmlNode<DOMSource> {
+    @Override
+    default Class<DOMSource> getValueObjectModel() {
+        return DOMSource.class;
+    }
+
     /**
      * Return value represented as a DOMSource. Returned source contains top level element
      * that duplicates the anyxml node.
diff --git a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/AnyxmlNode.java b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/AnyxmlNode.java
new file mode 100644 (file)
index 0000000..30134a6
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.data.api.schema;
+
+import com.google.common.annotations.Beta;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+
+/**
+ * A NormalizedNode holding the contents of an {@code anyxml} node in some object model. This interface is a common
+ * capture for all object model specializations.
+ *
+ * @param <V> Value type, uniquely identifying the object model used for values
+ */
+@Beta
+public interface AnyxmlNode<V> extends ForeignDataNode<NodeIdentifier, V> {
+
+}
diff --git a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/ForeignDataNode.java b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/ForeignDataNode.java
new file mode 100644 (file)
index 0000000..0db638a
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.data.api.schema;
+
+import com.google.common.annotations.Beta;
+import javax.xml.transform.dom.DOMSource;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+
+/**
+ * A NormalizedNode holding a value in some foreign object model. The object model is identified by a single class,
+ * which must be the superclass of (or interface implemented by) all objects used to anchor that object model into
+ * NormalizedNode model.
+ *
+ * <p>
+ * This interface should not be implemented directly, but rather further specialized, like {@link AnyxmlNode}.
+ *
+ * @param <K> Local identifier of node
+ * @param <V> Value type, uniquely identifying the object model used for values
+ */
+@Beta
+public interface ForeignDataNode<K extends PathArgument, V> extends DataContainerChild<K, V> {
+    /**
+     * Return the object model class, which identifies it. For example {@link AnyXmlNode} uses {@link DOMSource} as
+     * its value object model.
+     *
+     * @return Object model class
+     */
+    @NonNull Class<V> getValueObjectModel();
+}