From 7ec9c31b1cbdfb6d29baa1589cb592354ea539b7 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 26 Jul 2016 23:38:12 +0200 Subject: [PATCH] Introduce common interface for getValue() method 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 --- .../yang/data/api/schema/LeafNode.java | 10 ++---- .../data/api/schema/LeafSetEntryNode.java | 18 ++-------- .../yang/data/api/schema/NormalizedNode.java | 6 ++-- .../yang/data/api/schema/ValueNode.java | 34 +++++++++++++++++++ 4 files changed, 41 insertions(+), 27 deletions(-) create mode 100644 yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/ValueNode.java diff --git a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/LeafNode.java b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/LeafNode.java index 38aee4f11b..8dcdfde984 100644 --- a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/LeafNode.java +++ b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/LeafNode.java @@ -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 Value type */ -public interface LeafNode extends // - AttributesContainer, - DataContainerChild { - +public interface LeafNode extends AttributesContainer, DataContainerChild, + ValueNode { /** - * * Returns value of this leaf node * * @return Returned value of this leaf node. Value SHOULD meet criteria defined by schema. - * */ @Override T getValue(); - } diff --git a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/LeafSetEntryNode.java b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/LeafSetEntryNode.java index af6eeaa910..ede054e45a 100644 --- a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/LeafSetEntryNode.java +++ b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/LeafSetEntryNode.java @@ -21,7 +21,8 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithV * @param * Value type */ -public interface LeafSetEntryNode extends AttributesContainer, NormalizedNode { +public interface LeafSetEntryNode extends AttributesContainer, NormalizedNode, + ValueNode { /** * Returns {@link NodeWithValue} which identifies this leaf set entry. @@ -40,19 +41,4 @@ public interface LeafSetEntryNode extends AttributesContainer, NormalizedNode */ @Override NodeWithValue getIdentifier(); - - /** - * - * Returns value of this leaf node - * - *

Implementation notes

Invocation of {@link #getValue()} must - * provides same value as value in {@link #getIdentifier()}. - * true == this.getIdentifier().getValue().equals(this.getValue()) - * - * @return Returned value of this leaf node. Value SHOULD meet criteria - * defined by schema. - * - */ - @Override - T getValue(); } diff --git a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/NormalizedNode.java b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/NormalizedNode.java index c1aa3bbf50..deb69732bc 100644 --- a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/NormalizedNode.java +++ b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/NormalizedNode.java @@ -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 Local identifier of node * @param Value of node */ -public interface NormalizedNode extends Identifiable { +public interface NormalizedNode extends Identifiable { /** * 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 index 0000000000..eb70bfaa98 --- /dev/null +++ b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/ValueNode.java @@ -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 Local identifier of node + * @param Value of node + */ +public interface ValueNode extends NormalizedNode { + /** + * Returns value of held by this node. + * + *

Implementation notes

Invocation of {@link #getValue()} must + * provides same value as value in {@link #getIdentifier()}. + * true == this.getIdentifier().getValue().equals(this.getValue()) + * + * @return Returned value of this node. Value SHOULD meet criteria + * defined by schema. + * + */ + @Override + V getValue(); +} -- 2.36.6