Deprecate CopyableNode at al. 52/67752/3
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 30 Jan 2018 22:48:40 +0000 (23:48 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 2 Feb 2018 01:09:17 +0000 (02:09 +0100)
isAddedByUses(), isAugmenting() and similar constructs relate to how
a particular node became effective. This really has not place in the
effective model of the world.

This patch concentrates duplicate methods into an interface hierarchy
and marks them as @deprecated, along with justification. This allows
us to track down users and the semantics they really are after.

Since we are touching SchemaContext, mark its future direction, which
should see it shed a lot of nonsensical methods.

Change-Id: Ibdaf52e45076006e979204ac75e7bae6aeffd29a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
17 files changed:
yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/YangModeledAnyxmlEffectiveStatementImpl.java
yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/ContainerSchemaNodes.java
yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/RpcAsContainer.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/AddedByUsesAware.java [new file with mode: 0644]
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/CopyableNode.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/GroupingDefinition.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaContext.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/UnknownSchemaNode.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/UsesNode.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/AbstractSchemaContext.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveDataSchemaNode.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveSimpleDataNodeContainer.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/UnknownEffectiveStatementBase.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/action/ActionEffectiveStatementImpl.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/choice/ImplicitCaseSchemaNode.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/notification/NotificationEffectiveStatementImpl.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/uses/UsesEffectiveStatementImpl.java

index 48e7ea5207d24a9eba0ffe209d79309995892a5b..f201f7c4849a2b1edcf6c436e855d094ab1bf14d 100644 (file)
@@ -84,11 +84,13 @@ final class YangModeledAnyxmlEffectiveStatementImpl
         return delegateSchemaNode().getReference();
     }
 
+    @Deprecated
     @Override
     public boolean isAugmenting() {
         return delegateSchemaNode().isAugmenting();
     }
 
+    @Deprecated
     @Override
     public boolean isAddedByUses() {
         return delegateSchemaNode().isAddedByUses();
index c345a851770f61f8ac12a39bd2cdb11e1bfa14ea..2d748c473961bc676c59283aedfcca861b5e7258 100644 (file)
@@ -181,6 +181,7 @@ public final class ContainerSchemaNodes {
             }
         }
 
+        @Deprecated
         @Override
         public boolean isAddedByUses() {
             return false;
@@ -239,6 +240,7 @@ public final class ContainerSchemaNodes {
         }
 
         @Override
+        @Deprecated
         public boolean isAddedByUses() {
             //FIXME: reference to https://bugs.opendaylight.org/show_bug.cgi?id=6897
             return false;
index 498b41d56ed42f3833859a3f2318f4f6727a3b35..b524271f1479c0cb1eec23667a54fabed2df7451 100644 (file)
@@ -133,11 +133,13 @@ public final class RpcAsContainer implements ContainerSchemaNode {
         return ret;
     }
 
+    @Deprecated
     @Override
     public boolean isAugmenting() {
         return false;
     }
 
+    @Deprecated
     @Override
     public boolean isAddedByUses() {
         return false;
diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/AddedByUsesAware.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/AddedByUsesAware.java
new file mode 100644 (file)
index 0000000..94a91bd
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2018 Pantheon Technologies, 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.model.api;
+
+/**
+ * Trait interface for {@link SchemaNode}s, which have the {@link #isAddedByUses()} method.
+ *
+ * @deprecated This interface relates to declared model rather than to effective mode and as such should not
+ *             exist. It is provided to provide common method definition and eash migration of users.
+ */
+@Deprecated
+public interface AddedByUsesAware {
+    /**
+     * Returns <code>true</code> if this node was added by uses statement,
+     * otherwise returns <code>false</code>.
+     *
+     * @return <code>true</code> if this node was added by uses statement,
+     *         otherwise returns <code>false</code>
+     */
+    boolean isAddedByUses();
+}
index 4dba5a251d1e16ea6e3cef7012d3204e8a33677e..b7f38a8426f06d75e8e5e826c2587875e1015995 100644 (file)
@@ -7,13 +7,17 @@
  */
 package org.opendaylight.yangtools.yang.model.api;
 
-import com.google.common.annotations.Beta;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 
 /**
  * Represents a node that can be added by uses or by augmentation.
+ *
+ * @deprecated Aside from the deprecated {@link AddedByUsesAware} contract, this interface adds only a trait related
+ *             to now how we arrived at this effective node. Users who need to know this information should really be
+ *             looking at the {@link DeclaredStatement} world, which holds the original node definition.
  */
-@Beta
-public interface CopyableNode {
+@Deprecated
+public interface CopyableNode extends AddedByUsesAware {
     /**
      * Returns <code>true</code> if this node was added by augmentation,
      * otherwise returns <code>false</code>.
@@ -22,13 +26,4 @@ public interface CopyableNode {
      *         otherwise returns <code>false</code>
      */
     boolean isAugmenting();
-
-    /**
-     * Returns <code>true</code> if this node was added by uses statement,
-     * otherwise returns <code>false</code>.
-     *
-     * @return <code>true</code> if this node was added by uses statement,
-     *         otherwise returns <code>false</code>
-     */
-    boolean isAddedByUses();
 }
index 16318910e96a3e3490f57b115f48996571e1fef7..9258675cf2f829cf627a2c9c52b2c548b2e2dea2 100644 (file)
@@ -13,15 +13,13 @@ package org.opendaylight.yangtools.yang.model.api;
  * <p>
  * It is used to define a reusable block of nodes, which may be used locally in
  * the module, in modules that include it, and by other modules that import from it.
+ *
+ * <p>
+ * Note: this interface extends {@link AddedByUsesAware}, but this contradicts the javadoc of {@link #isAddedByUses()},
+ *       as groupings can never be encountered in 'data schema node' context. It is their children, which are data
+ *       schema node, but those really are instantiated and typically differ in {@link #getQName()}'s namespace.
  */
 public interface GroupingDefinition extends DataNodeContainer, SchemaNode, NotificationNodeContainer,
-       ActionNodeContainer {
-    /**
-     * Returns <code>true</code> if the data node was added by uses statement,
-     * otherwise returns <code>false</code>.
-     *
-     * @return <code>true</code> if the data node was added by uses statement,
-     *         otherwise returns <code>false</code>
-     */
-    boolean isAddedByUses();
+       ActionNodeContainer, AddedByUsesAware {
+
 }
index 50311a1c5e163fea1a93f52112b4d3533adf242f..9a5c88593c2b9a155fcefb8fb2b65f05a5493eee 100644 (file)
@@ -28,6 +28,8 @@ import org.opendaylight.yangtools.yang.common.Revision;
  * environment is safe.
  */
 @Immutable
+// FIXME: 3.0.0: ContainerSchemaNode is far too broad. A combination of DataNodeContainer, NotificationNodeContainer
+//               and possibly DataSchemaNode would reflect SchemaContext traits better.
 public interface SchemaContext extends ContainerSchemaNode {
     /**
      * QName of NETCONF top-level data node.
index cd9fb7ad2719c7e05b4405b76114b925d966c09b..274c46597321cc6892f9f854e0589975639acfdc 100644 (file)
@@ -12,7 +12,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 /**
  * Contains the methods for getting the details about the unknown node.
  */
-public interface UnknownSchemaNode extends SchemaNode {
+public interface UnknownSchemaNode extends SchemaNode, AddedByUsesAware {
     /**
      * Returns QName instance with the name of the unknown node.
      *
@@ -27,22 +27,18 @@ public interface UnknownSchemaNode extends SchemaNode {
      */
     String getNodeParameter();
 
-    /**
-     * Describes whether the node was added through <code>uses</code> YANG
-     * keyword.
-     *
-     * @return boolean value which is <code>true</code> if the node is added by
-     *         <code>uses</code> YANG keyword
-     */
-    boolean isAddedByUses();
-
     /**
      * Describes whether the node was added through <code>augment</code> YANG
      * statement.
      *
      * @return boolean value which is <code>true</code> if the node is added by
      *         <code>augment</code> YANG statement
+     *
+     * @deprecated This method exposes mechanism of how this node was instantiated. This runs contrary to the idea
+     *             that a SchemaNode is part of the effective model of the world. Examining a node's DeclaredStatement
+     *             world should be sufficient to ascertain its origin.
      */
+    @Deprecated
     boolean isAddedByAugmentation();
 
     /**
index b96d2b2bc0449e73e44eaa60cb36fece65980514..5d18a93449f34d3416b8b9dd2a5d1ce574fee94b 100644 (file)
@@ -15,7 +15,7 @@ import org.opendaylight.yangtools.yang.model.api.DocumentedNode.WithStatus;
 /**
  * Contains the methods for getting data and checking properties of the YANG <code>uses</code> substatement.
  */
-public interface UsesNode extends WhenConditionAware, WithStatus {
+public interface UsesNode extends WhenConditionAware, WithStatus, CopyableNode {
 
     /**
      * Returns the schema path to used grouping.
@@ -31,24 +31,6 @@ public interface UsesNode extends WhenConditionAware, WithStatus {
      */
     @Nonnull Set<AugmentationSchemaNode> getAugmentations();
 
-    /**
-     * Returns <code>true</code> if the data node was added by augmentation,
-     * otherwise returns <code>false</code>.
-     *
-     * @return <code>true</code> if the data node was added by augmentation,
-     *         otherwise returns <code>false</code>
-     */
-    boolean isAugmenting();
-
-    /**
-     * Returns <code>true</code> if the data node was added by uses statement,
-     * otherwise returns <code>false</code>.
-     *
-     * @return <code>true</code> if the data node was added by uses statement,
-     *         otherwise returns <code>false</code>
-     */
-    boolean isAddedByUses();
-
     /**
      * Some of the properties of each node in the grouping can be refined with
      * the "refine" statement.
index fa6779137325e98eba956161315294316b9a2a59..43b22a45c05dd8f221d3516f5042d07570f22a2f 100644 (file)
@@ -152,11 +152,13 @@ public abstract class AbstractSchemaContext implements SchemaContext {
         return getNameToModules().get(name);
     }
 
+    @Deprecated
     @Override
     public boolean isAugmenting() {
         return false;
     }
 
+    @Deprecated
     @Override
     public boolean isAddedByUses() {
         return false;
index 254ee289a5fd7caf8b684be4379f8c03494f3e21..0398c485b9a9589c8934095497a0f5e5bc948cdf 100644 (file)
@@ -43,11 +43,13 @@ public abstract class AbstractEffectiveDataSchemaNode<D extends DeclaredStatemen
         }
     }
 
+    @Deprecated
     @Override
     public final boolean isAugmenting() {
         return augmenting;
     }
 
+    @Deprecated
     @Override
     public final boolean isAddedByUses() {
         return addedByUses;
index de6d24aae8010630da39e7d7dc28802979638d5b..671174b767b3a18ee4dc850c2a9a28428c0502ba 100644 (file)
@@ -90,11 +90,13 @@ public abstract class AbstractEffectiveSimpleDataNodeContainer<D extends Declare
         return path;
     }
 
+    @Deprecated
     @Override
     public boolean isAugmenting() {
         return augmenting;
     }
 
+    @Deprecated
     @Override
     public boolean isAddedByUses() {
         return addedByUses;
index fde388da25ba8aab4fdea66a1d8b89e17580676f..6f768095cec40a16b63bf5c2dac44423964e3c5c 100644 (file)
@@ -74,6 +74,7 @@ public abstract class UnknownEffectiveStatementBase<A, D extends UnknownStatemen
         unknownNodes = builder.build();
     }
 
+    @Deprecated
     @Override
     public boolean isAddedByAugmentation() {
         return addedByAugmentation;
@@ -89,6 +90,7 @@ public abstract class UnknownEffectiveStatementBase<A, D extends UnknownStatemen
         return nodeParameter;
     }
 
+    @Deprecated
     @Override
     public boolean isAddedByUses() {
         return addedByUses;
index 83dcc8ffcba8344957ac7b3fa5256e3b8160e340..4a15b971374d87601c424bee707f6079fcd21503 100644 (file)
@@ -106,11 +106,13 @@ final class ActionEffectiveStatementImpl extends AbstractEffectiveSchemaNode<Act
         return groupings;
     }
 
+    @Deprecated
     @Override
     public boolean isAugmenting() {
         return augmenting;
     }
 
+    @Deprecated
     @Override
     public boolean isAddedByUses() {
         return addedByUses;
index 191718cd3251944b97ba1dfc4fca2e6b7ce33cab..fc678900a2a93460a2e02b2ad8d1bae2b1318c54 100644 (file)
@@ -48,11 +48,13 @@ public final class ImplicitCaseSchemaNode implements CaseSchemaNode, DerivableSc
         this.augmenting = caseShorthandNode.isAugmenting();
     }
 
+    @Deprecated
     @Override
     public boolean isAugmenting() {
         return augmenting;
     }
 
+    @Deprecated
     @Override
     public boolean isAddedByUses() {
         return caseShorthandNode.isAddedByUses();
index 02140d0fa15d138d904eb286b9e556e1ee6ca9e2..ac12fc5a1f15aaa8553c54bf879e83ec2c33ca27 100644 (file)
@@ -103,11 +103,13 @@ final class NotificationEffectiveStatementImpl
         return unknownNodes;
     }
 
+    @Deprecated
     @Override
     public boolean isAugmenting() {
         return augmenting;
     }
 
+    @Deprecated
     @Override
     public boolean isAddedByUses() {
         return addedByUses;
index 71bdc4acb8726b626d82e0abdad946cec3e5ca8a..8c783950c728ed04e936fcff256dc3fd6c6a083b 100644 (file)
@@ -96,11 +96,13 @@ final class UsesEffectiveStatementImpl extends AbstractEffectiveDocumentedNode<Q
         return augmentations;
     }
 
+    @Deprecated
     @Override
     public boolean isAugmenting() {
         return false;
     }
 
+    @Deprecated
     @Override
     public boolean isAddedByUses() {
         return addedByUses;