Add UnknownSchemaNodeMixin 22/90922/1
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 5 Jul 2020 18:28:20 +0000 (20:28 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 5 Jul 2020 18:28:39 +0000 (20:28 +0200)
Add basic mixin to use with effective statement implementations.

JIRA: YANGTOOLS-1123
Change-Id: Iaa0a7e9624d22999285d36f28ee6a0d797b936db
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/UnknownSchemaNode.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/EffectiveStatementMixins.java

index 274c46597321cc6892f9f854e0589975639acfdc..1549a29775fe26e137e9773136ae8d59c10e4166 100644 (file)
@@ -39,6 +39,7 @@ public interface UnknownSchemaNode extends SchemaNode, AddedByUsesAware {
      *             world should be sufficient to ascertain its origin.
      */
     @Deprecated
+    // FIXME: 6.0.0: rename this to isAugmenting(), unifying this interface with CopyableNode
     boolean isAddedByAugmentation();
 
     /**
index 76c31701ed0cb11544d6993a3470283eadda9663..6f723711f03bcc11fa5adcc32a138a958b07d31d 100644 (file)
@@ -11,6 +11,7 @@ import static com.google.common.base.Verify.verify;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects;
+import com.google.common.base.Strings;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableSet;
 import java.util.Collection;
@@ -304,6 +305,27 @@ public final class EffectiveStatementMixins {
         }
     }
 
+    /**
+     * Bridge between {@link EffectiveStatementWithFlags} and {@link UnknownSchemaNode}.
+     *
+     * @param <A> Argument type ({@link Void} if statement does not have argument.)
+     * @param <D> Class representing declared version of this statement.
+     */
+    public interface UnknownSchemaNodeMixin<A, D extends DeclaredStatement<A>>
+            extends SchemaNodeMixin<A, D>, CopyableMixin<A, D>, UnknownSchemaNode {
+
+        @Override
+        default String getNodeParameter() {
+            return Strings.nullToEmpty(getDeclared().rawArgument());
+        }
+
+        @Override
+        @Deprecated
+        default boolean isAddedByAugmentation() {
+            return isAugmenting();
+        }
+    }
+
     /**
      * Bridge between {@link EffectiveStatementWithFlags} and {@code ordered-by} statement.
      *