Introduce common interface for getValue() method 95/42595/3
authorRobert Varga <rovarga@cisco.com>
Tue, 26 Jul 2016 21:38:12 +0000 (23:38 +0200)
committerRobert Varga <rovarga@cisco.com>
Wed, 27 Jul 2016 19:49:20 +0000 (21:49 +0200)
LeafNode and LeafSetEntryNode both share this method. Codec-type users
benefit from being able to call on a common interface bridging the two
otherwise unrelated classes.

Change-Id: I5ef86c6859cf6cb7620aa3e4477941f248640c4f
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/LeafNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/LeafSetEntryNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/NormalizedNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/ValueNode.java [new file with mode: 0644]

index 38aee4f11b3a923ed7c3a5e257f65ac3bfe87551..8dcdfde984d3a093c7e7bdd3bf29938a4615c4cf 100644 (file)
@@ -11,7 +11,6 @@ import org.opendaylight.yangtools.yang.data.api.AttributesContainer;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 
 /**
- *
  * Leaf node with multiplicity 0..1
  *
  * Leaf node has a value, but no child nodes in the data tree, schema
@@ -19,19 +18,14 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
  *
  * @param <T> Value type
  */
-public interface LeafNode<T> extends //
-        AttributesContainer,
-        DataContainerChild<NodeIdentifier, T> {
-
+public interface LeafNode<T> extends AttributesContainer, DataContainerChild<NodeIdentifier, T>,
+        ValueNode<NodeIdentifier, T> {
 
     /**
-     *
      * Returns value of this leaf node
      *
      * @return Returned value of this leaf node. Value SHOULD meet criteria defined by schema.
-     *
      */
     @Override
     T getValue();
-
 }
index af6eeaa91098ac01549f678b43961fc124a0ef88..ede054e45ab6149828afebc135ab755346a8880b 100644 (file)
@@ -21,7 +21,8 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithV
  * @param <T>
  *            Value type
  */
-public interface LeafSetEntryNode<T> extends AttributesContainer, NormalizedNode<NodeWithValue, T> {
+public interface LeafSetEntryNode<T> extends AttributesContainer, NormalizedNode<NodeWithValue, T>,
+        ValueNode<NodeWithValue, T> {
 
     /**
      * Returns {@link NodeWithValue} which identifies this leaf set entry.
@@ -40,19 +41,4 @@ public interface LeafSetEntryNode<T> extends AttributesContainer, NormalizedNode
      */
     @Override
     NodeWithValue getIdentifier();
-
-    /**
-     *
-     * Returns value of this leaf node
-     *
-     * <h3>Implementation notes</h3> Invocation of {@link #getValue()} must
-     * provides same value as value in {@link #getIdentifier()}.
-     * <code>true == this.getIdentifier().getValue().equals(this.getValue())</code>
-     *
-     * @return Returned value of this leaf node. Value SHOULD meet criteria
-     *         defined by schema.
-     *
-     */
-    @Override
-    T getValue();
 }
index c1aa3bbf50deb17fc8d4fce225b890a63b1cb886..deb69732bcc39dc8493021048f3895381e510077 100644 (file)
@@ -9,12 +9,12 @@ package org.opendaylight.yangtools.yang.data.api.schema;
 
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 
 /**
  *
  * Node which is normalized according to the YANG schema
- * is identifiable by {@link YangInstanceIdentifier}.
+ * is identifiable by a {@link org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier}.
  *
  * See subinterfaces of this interface for concretization
  * of node.
@@ -22,7 +22,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
  * @param <K> Local identifier of node
  * @param <V> Value of node
  */
-public interface NormalizedNode<K extends YangInstanceIdentifier.PathArgument, V> extends Identifiable<K> {
+public interface NormalizedNode<K extends PathArgument, V> extends Identifiable<K> {
     /**
      * QName of the node as defined in YANG schema.
      *
diff --git a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/ValueNode.java b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/ValueNode.java
new file mode 100644 (file)
index 0000000..eb70bfa
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. 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 org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+
+/**
+ * Interface holding the common trait of {@link LeafSetEntryNode} and {@link LeafNode}, which both hold a value.
+ *
+ * @author Robert Varga
+ *
+ * @param <K> Local identifier of node
+ * @param <V> Value of node
+ */
+public interface ValueNode<K extends PathArgument, V> extends NormalizedNode<K, V> {
+    /**
+     * Returns value of held by this node.
+     *
+     * <h3>Implementation notes</h3> Invocation of {@link #getValue()} must
+     * provides same value as value in {@link #getIdentifier()}.
+     * <code>true == this.getIdentifier().getValue().equals(this.getValue())</code>
+     *
+     * @return Returned value of this node. Value SHOULD meet criteria
+     *         defined by schema.
+     *
+     */
+    @Override
+    V getValue();
+}