Refactor simple effective statements 80/86880/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 8 Jan 2020 20:21:16 +0000 (21:21 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 14 Jan 2020 15:22:54 +0000 (16:22 +0100)
Currently DescriptionEffectiveStatementImpl takes 32 bytes in typical
Linux environment, which is not much, but for well-documented models this
can amount to 8% of the cost of a SchemaContext.

The primary cause is of course is inlining of groupings, but even if that
is fixed we will end up with at least one instance for each description,
so sizing here is important.

We can get rid of this cost by decomposing the implementation by known
DescriptionEffectiveStatement invariants, so that we end up with using
16 (typical) or 24 bytes in the same environment. Worst case size is
reduced to 24 (typical) or 32 bytes (from 48). The overall benefit is
expected to be around 4% SchemaContext size.

Apply the same refactor to reference, contact, belongs-to, ordered-by,
default, error-app-tag, error-message, prefix, presence, reference, units.

JIRA: YANGTOOLS-1065
Change-Id: Ic8da0c38cd89ae10c66ebb70719cf582cb0f627b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 312068b3e5eca1b3c336fa029a5a81c7b6a031c0)

51 files changed:
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractDeclaredEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/BaseStatementSupport.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/BaseStringStatementSupport.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/DeclaredEffectiveStatementBase.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/EffectiveStatementBase.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/belongs_to/AbstractBelongsToEffectiveStatement.java [moved from yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/belongs_to/BelongsToEffectiveStatementImpl.java with 53% similarity]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/belongs_to/BelongsToStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/belongs_to/EmptyBelongsToEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/belongs_to/RegularBelongsToEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/contact/AbstractContactEffectiveStatement.java [moved from yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/contact/ContactEffectiveStatementImpl.java with 53% similarity]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/contact/ContactStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/contact/EmptyContactEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/contact/RegularContactEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/default_/AbstractDefaultEffectiveStatement.java [moved from yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/default_/DefaultEffectiveStatementImpl.java with 53% similarity]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/default_/DefaultStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/default_/EmptyDefaultEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/default_/RegularDefaultEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/description/AbstractDescriptionEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/description/DescriptionEffectiveStatementImpl.java [deleted file]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/description/DescriptionStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/description/EmptyDescriptionEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/description/RegularDescriptionEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_app_tag/AbstractErrorAppTagEffectiveStatement.java [moved from yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_app_tag/ErrorAppTagEffectiveStatementImpl.java with 53% similarity]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_app_tag/EmptyErrorAppTagEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_app_tag/ErrorAppTagStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_app_tag/RegularErrorAppTagEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_message/AbstractErrorMessageEffectiveStatement.java [moved from yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_message/ErrorMessageEffectiveStatementImpl.java with 52% similarity]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_message/EmptyErrorMessageEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_message/ErrorMessageStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_message/RegularErrorMessageEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/ordered_by/AbstractOrderedByEffectiveStatement.java [moved from yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/ordered_by/OrderedByEffectiveStatementImpl.java with 53% similarity]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/ordered_by/EmptyOrderedByEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/ordered_by/OrderedByStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/ordered_by/RegularOrderedByEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/prefix/AbstractPrefixEffectiveStatement.java [moved from yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/prefix/PrefixEffectiveStatementImpl.java with 53% similarity]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/prefix/EmptyPrefixEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/prefix/PrefixStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/prefix/RegularPrefixEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/presence/AbstractPresenceEffectiveStatement.java [moved from yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/presence/PresenceEffectiveStatementImpl.java with 53% similarity]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/presence/EmptyPresenceEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/presence/PresenceStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/presence/RegularPresenceEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/reference/AbstractReferenceEffectiveStatement.java [moved from yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/reference/ReferenceEffectiveStatementImpl.java with 53% similarity]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/reference/EmptyReferenceEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/reference/ReferenceStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/reference/RegularReferenceEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/units/AbstractUnitsEffectiveStatement.java [moved from yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/units/UnitsEffectiveStatementImpl.java with 53% similarity]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/units/EmptyUnitsEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/units/RegularUnitsEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/units/UnitsStatementSupport.java

diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractDeclaredEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractDeclaredEffectiveStatement.java
new file mode 100644 (file)
index 0000000..5b9edf3
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.annotations.Beta;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
+
+/**
+ * Base stateless superclass for statements which (logically) always have an associated {@link DeclaredStatement}. This
+ * is notably not true for all {@code case} statements, some of which may actually be implied.
+ *
+ * <p>
+ * Note implementations are not strictly required to make the declared statement available, they are free to throw
+ * {@link UnsupportedOperationException} from {@link #getDeclared()}, rendering any services relying on declared
+ * statement to be not available.
+ *
+ * @param <A> Argument type ({@link Void} if statement does not have argument.)
+ * @param <D> Class representing declared version of this statement.
+ */
+@Beta
+public abstract class AbstractDeclaredEffectiveStatement<A, D extends DeclaredStatement<A>>
+        extends AbstractEffectiveStatement<A, D> {
+    @Override
+    public final StatementSource getStatementSource() {
+        return StatementSource.DECLARATION;
+    }
+
+    @Override
+    public final StatementDefinition statementDefinition() {
+        return getDeclared().statementDefinition();
+    }
+
+    @Override
+    public abstract @NonNull D getDeclared();
+
+    /**
+     * A stateful version of {@link AbstractDeclaredEffectiveStatement}, which holds (and requires) a declared
+     * statement.
+     *
+     * @param <A> Argument type ({@link Void} if statement does not have argument.)
+     * @param <D> Class representing declared version of this statement.
+     */
+    public abstract static class Default<A, D extends DeclaredStatement<A>>
+            extends AbstractDeclaredEffectiveStatement<A, D> {
+        private final @NonNull D declared;
+
+        protected Default(final D declared) {
+            this.declared = requireNonNull(declared);
+        }
+
+        @Override
+        public final D getDeclared() {
+            return declared;
+        }
+    }
+
+    /**
+     * An extra building block on top of {@link Default}, which is wiring {@link #argument()} to the declared statement.
+     * This is mostly useful for arguments that are not subject to inference transformation -- for example Strings in
+     * {@code description}, etc. This explicitly is not true of statements which underwent namespace binding via
+     * {@code uses} or similar.
+     *
+     * @param <A> Argument type ({@link Void} if statement does not have argument.)
+     * @param <D> Class representing declared version of this statement.
+     */
+    public abstract static class DefaultArgument<A, D extends DeclaredStatement<A>> extends Default<A, D> {
+        protected DefaultArgument(final D declared) {
+            super(declared);
+        }
+
+        @Override
+        public final @Nullable A argument() {
+            return getDeclared().argument();
+        }
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveStatement.java
new file mode 100644 (file)
index 0000000..3ba956c
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+
+/**
+ * Baseline stateless implementation of an EffectiveStatement. This class adds a few default implementations and
+ * namespace dispatch, but does not actually force any state on its subclasses. This approach is different from
+ * {@link EffectiveStatementBase} in that it adds requirements for an implementation, but it leaves it up to the final
+ * class to provide object layout.
+ *
+ * <p>
+ * This finds immense value in catering the common case, for example effective statements which can, but typically
+ * do not, contain substatements.
+ *
+ * @param <A> Argument type ({@link Void} if statement does not have argument.)
+ * @param <D> Class representing declared version of this statement.
+ */
+@Beta
+public abstract class AbstractEffectiveStatement<A, D extends DeclaredStatement<A>>
+        implements EffectiveStatement<A, D> {
+    @Override
+    public final <K, V, N extends IdentifierNamespace<K, V>> V get(final Class<N> namespace, final K identifier) {
+        return getAll(namespace).get(requireNonNull(identifier));
+    }
+
+    @Override
+    public final <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAll(final Class<N> namespace) {
+        final Optional<? extends Map<K, V>> ret = getNamespaceContents(requireNonNull(namespace));
+        return ret.isPresent() ? ret.get() : ImmutableMap.of();
+    }
+
+    /**
+     * Return the statement-specific contents of specified namespace, if available.
+     *
+     * @param namespace Requested namespace
+     * @return Namespace contents, if available.
+     */
+    protected <K, V, N extends IdentifierNamespace<K, V>> Optional<? extends Map<K, V>> getNamespaceContents(
+            final @NonNull Class<N> namespace) {
+        return Optional.empty();
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/BaseStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/BaseStatementSupport.java
new file mode 100644 (file)
index 0000000..012d7cb
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt;
+
+import static com.google.common.base.Verify.verifyNotNull;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableList;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+/**
+ * Implementation-internal base class for {@link AbstractStatementSupport} implementations.
+ *
+ * @param <A> Argument type
+ * @param <D> Declared Statement representation
+ * @param <E> Effective Statement representation
+ */
+@Beta
+public abstract class BaseStatementSupport<A, D extends DeclaredStatement<A>,
+        E extends EffectiveStatement<A, D>> extends AbstractStatementSupport<A, D, E> {
+    protected BaseStatementSupport(final StatementDefinition publicDefinition) {
+        super(publicDefinition);
+    }
+
+    @Override
+    public final E createEffective(final StmtContext<A, D, E> ctx) {
+        final D declared = buildDeclared(ctx);
+        final ImmutableList<? extends EffectiveStatement<?, ?>> substatements = buildEffectiveSubstatements(ctx);
+        return substatements.isEmpty() ? createEmptyEffective(ctx, declared)
+                : createEffective(ctx, declared, substatements);
+    }
+
+    protected abstract @NonNull E createEffective(@NonNull StmtContext<A, D, E> ctx, @NonNull D declared,
+            @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements);
+
+    protected abstract @NonNull E createEmptyEffective(@NonNull StmtContext<A, D, E> ctx, @NonNull D declared);
+
+    static final <A, D extends DeclaredStatement<A>> @NonNull D buildDeclared(final StmtContext<A, D, ?> ctx) {
+        /*
+         * Share original instance of declared statement between all effective
+         * statements which have been copied or derived from this original
+         * declared statement.
+         */
+        @SuppressWarnings("unchecked")
+        final StmtContext<?, D, ?> lookupCtx = (StmtContext<?, D, ?>) ctx.getOriginalCtx().orElse(ctx);
+        return verifyNotNull(lookupCtx.buildDeclared(), "Statement %s failed to build declared statement", lookupCtx);
+    }
+
+    /**
+     * Create a set of substatements. This method is split out so it can be overridden in
+     * ExtensionEffectiveStatementImpl to leak a not-fully-initialized instance.
+     *
+     * @param substatements proposed substatements
+     * @return Filtered substatements
+     */
+    private static ImmutableList<? extends EffectiveStatement<?, ?>> buildEffectiveSubstatements(
+            final List<? extends StmtContext<?, ?, ?>> substatements) {
+        return substatements.stream()
+                .filter(StmtContext::isSupportedToBuildEffective)
+                .map(StmtContext::buildEffective)
+                .collect(ImmutableList.toImmutableList());
+    }
+
+    static final ImmutableList<? extends EffectiveStatement<?, ?>> buildEffectiveSubstatements(
+            final StmtContext<?, ?, ?> ctx) {
+        return buildEffectiveSubstatements(declaredSubstatements(ctx));
+    }
+
+    static final @NonNull List<StmtContext<?, ?, ?>> declaredSubstatements(final StmtContext<?, ?, ?> ctx) {
+        /*
+         * This dance is required to ensure that effects of 'uses' nodes are applied in the same order as
+         * the statements were defined -- i.e. if we have something like this:
+         *
+         * container foo {
+         *   uses bar;
+         *   uses baz;
+         * }
+         *
+         * grouping baz {
+         *   leaf baz {
+         *     type string;
+         *   }
+         * }
+         *
+         * grouping bar {
+         *   leaf bar {
+         *     type string;
+         *   }
+         * }
+         *
+         * The reactor would first inline 'uses baz' as that definition is the first one completely resolved and then
+         * inline 'uses bar'. Here we are iterating in declaration order re-inline the statements.
+         *
+         * FIXME: 5.0.0: this really should be handled by UsesStatementSupport such that 'uses baz' would have a
+         *               prerequisite of a resolved 'uses bar'.
+         */
+        final List<StmtContext<?, ?, ?>> substatementsInit = new ArrayList<>();
+        Set<StmtContext<?, ?, ?>> filteredStatements = null;
+        for (final StmtContext<?, ?, ?> declaredSubstatement : ctx.declaredSubstatements()) {
+            if (declaredSubstatement.isSupportedByFeatures()) {
+                substatementsInit.add(declaredSubstatement);
+
+                final Collection<? extends StmtContext<?, ?, ?>> effect = declaredSubstatement.getEffectOfStatement();
+                if (!effect.isEmpty()) {
+                    if (filteredStatements == null) {
+                        filteredStatements = new HashSet<>();
+                    }
+                    filteredStatements.addAll(effect);
+                    substatementsInit.addAll(effect);
+                }
+            }
+        }
+
+        if (filteredStatements != null) {
+            for (StmtContext<?, ?, ?> stmt : ctx.effectiveSubstatements()) {
+                if (!filteredStatements.contains(stmt)) {
+                    substatementsInit.add(stmt);
+                }
+            }
+        } else {
+            substatementsInit.addAll(ctx.effectiveSubstatements());
+        }
+
+        return substatementsInit;
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/BaseStringStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/BaseStringStatementSupport.java
new file mode 100644 (file)
index 0000000..416579b
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt;
+
+import com.google.common.annotations.Beta;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+
+/**
+ * Specialization of {@link BaseStatementSupport} for String statement arguments.
+ *
+ * @param <D> Declared Statement representation
+ * @param <E> Effective Statement representation
+ */
+@Beta
+public abstract class BaseStringStatementSupport<D extends DeclaredStatement<String>,
+        E extends EffectiveStatement<String, D>> extends BaseStatementSupport<String, D, E> {
+    protected BaseStringStatementSupport(final StatementDefinition publicDefinition) {
+        super(publicDefinition);
+    }
+}
index b78b57157afb46067ad1866d36b795a34b713bd7..859e09d835e766c89f7eef63ebd22a211c18dde8 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt;
 
-import com.google.common.base.Verify;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
@@ -29,19 +28,9 @@ public abstract class DeclaredEffectiveStatementBase<A, D extends DeclaredStatem
      */
     protected DeclaredEffectiveStatementBase(final StmtContext<A, D, ?> ctx) {
         super(ctx);
-
-        this.argument = ctx.getStatementArgument();
-        this.statementSource = ctx.getStatementSource();
-
-        /*
-         * Share original instance of declared statement between all effective
-         * statements which have been copied or derived from this original
-         * declared statement.
-         */
-        @SuppressWarnings("unchecked")
-        final StmtContext<?, D, ?> lookupCtx = (StmtContext<?, D, ?>) ctx.getOriginalCtx().orElse(ctx);
-        declaredInstance = Verify.verifyNotNull(lookupCtx.buildDeclared(),
-            "Statement %s failed to build declared statement", lookupCtx);
+        argument = ctx.getStatementArgument();
+        statementSource = ctx.getStatementSource();
+        declaredInstance = BaseStatementSupport.buildDeclared(ctx);
     }
 
     @Override
index e078fa2fcb8f8282feff20a45f914e72d420add3..97f7ca2ce2f75f4826cab9e8da3f60962ec1ed7d 100644 (file)
@@ -7,27 +7,33 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt;
 
-import static java.util.Objects.requireNonNull;
-
 import com.google.common.annotations.Beta;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableList;
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
 import java.util.function.Predicate;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
-public abstract class EffectiveStatementBase<A, D extends DeclaredStatement<A>> implements EffectiveStatement<A, D> {
+/**
+ * Stateful version of {@link AbstractEffectiveStatement}, which holds substatements in an {@link ImmutableList}.
+ *
+ * @param <A> Argument type ({@link Void} if statement does not have argument.)
+ * @param <D> Class representing declared version of this statement.
+ */
+// TODO: This class is problematic in that it interacts with its subclasses via methods which are guaranteed to allows
+//       atrocities like RecursiveObjectLeaker tricks. That should be avoided and pushed to caller in a way where
+//       this class is a pure holder taking {@code ImmutableList<? extends EffectiveStatement<?, ?>>} in the
+//       constructor.
+//
+//       From memory efficiency perspective, it is very common to have effective statements without any substatements,
+//       in which case 'substatements' field is redundant.
+public abstract class EffectiveStatementBase<A, D extends DeclaredStatement<A>>
+        extends AbstractEffectiveStatement<A, D> {
     private final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements;
 
     /**
@@ -36,62 +42,8 @@ public abstract class EffectiveStatementBase<A, D extends DeclaredStatement<A>>
      * @param ctx context of statement.
      */
     protected EffectiveStatementBase(final StmtContext<A, D, ?> ctx) {
-        final Collection<StmtContext<?, ?, ?>> substatementsInit = new ArrayList<>();
-
-        /*
-         * This dance is required to ensure that effects of 'uses' nodes are applied in the same order as
-         * the statements were defined -- i.e. if we have something like this:
-         *
-         * container foo {
-         *   uses bar;
-         *   uses baz;
-         * }
-         *
-         * grouping baz {
-         *   leaf baz {
-         *     type string;
-         *   }
-         * }
-         *
-         * grouping bar {
-         *   leaf bar {
-         *     type string;
-         *   }
-         * }
-         *
-         * The reactor would first inline 'uses baz' as that definition is the first one completely resolved and then
-         * inline 'uses bar'. Here we are iterating in declaration order re-inline the statements.
-         *
-         * TODO: this really should be handled by UsesStatementSupport such that 'uses baz' would have a prerequisite
-         *       of a resolved 'uses bar'.
-         */
-        Set<StmtContext<?, ?, ?>> filteredStatements = null;
-        for (final StmtContext<?, ?, ?> declaredSubstatement : ctx.declaredSubstatements()) {
-            if (declaredSubstatement.isSupportedByFeatures()) {
-                substatementsInit.add(declaredSubstatement);
-
-                final Collection<? extends StmtContext<?, ?, ?>> effect = declaredSubstatement.getEffectOfStatement();
-                if (!effect.isEmpty()) {
-                    if (filteredStatements == null) {
-                        filteredStatements = new HashSet<>();
-                    }
-                    filteredStatements.addAll(effect);
-                    substatementsInit.addAll(effect);
-                }
-            }
-        }
-
-        if (filteredStatements != null) {
-            for (StmtContext<?, ?, ?> stmt : ctx.effectiveSubstatements()) {
-                if (!filteredStatements.contains(stmt)) {
-                    substatementsInit.add(stmt);
-                }
-            }
-        } else {
-            substatementsInit.addAll(ctx.effectiveSubstatements());
-        }
-
-        this.substatements = ImmutableList.copyOf(initSubstatements(ctx, substatementsInit));
+        this.substatements = ImmutableList.copyOf(initSubstatements(ctx,
+            BaseStatementSupport.declaredSubstatements(ctx)));
     }
 
     @Beta
@@ -113,53 +65,32 @@ public abstract class EffectiveStatementBase<A, D extends DeclaredStatement<A>>
             StmtContext::isSupportedToBuildEffective), StmtContext::buildEffective);
     }
 
-    @Override
-    public final <K, V, N extends IdentifierNamespace<K, V>> V get(final Class<N> namespace, final K identifier) {
-        return findAll(namespace).get(requireNonNull(identifier));
-    }
-
-    @Override
-    public final <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAll(final Class<N> namespace) {
-        return getNamespaceContents(requireNonNull(namespace)).orElse(null);
-    }
-
-    /**
-     * Return the statement-specific contents of specified namespace, if available.
-     *
-     * @param namespace Requested namespace
-     * @return Namespace contents, if available.
-     */
-    @Beta
-    protected <K, V, N extends IdentifierNamespace<K, V>> Optional<? extends Map<K, V>> getNamespaceContents(
-            final @NonNull Class<N> namespace) {
-        return Optional.empty();
-    }
-
     @Override
     public final Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
         return substatements;
     }
 
-    protected final <S extends SchemaNode> S firstSchemaNode(final Class<S> type) {
-        return substatements.stream().filter(type::isInstance).findFirst().map(type::cast).orElse(null);
-    }
-
     @SuppressWarnings("unchecked")
     public final <T> Collection<T> allSubstatementsOfType(final Class<T> type) {
-        return Collection.class.cast(Collections2.filter(substatements, type::isInstance));
+        return Collection.class.cast(Collections2.filter(effectiveSubstatements(), type::isInstance));
     }
 
     protected final <T> @Nullable T firstSubstatementOfType(final Class<T> type) {
-        return substatements.stream().filter(type::isInstance).findFirst().map(type::cast).orElse(null);
+        return effectiveSubstatements().stream().filter(type::isInstance).findFirst().map(type::cast).orElse(null);
     }
 
     protected final <R> R firstSubstatementOfType(final Class<?> type, final Class<R> returnType) {
-        return substatements.stream()
+        return effectiveSubstatements().stream()
                 .filter(((Predicate<Object>)type::isInstance).and(returnType::isInstance))
                 .findFirst().map(returnType::cast).orElse(null);
     }
 
     protected final EffectiveStatement<?, ?> firstEffectiveSubstatementOfType(final Class<?> type) {
-        return substatements.stream().filter(type::isInstance).findFirst().orElse(null);
+        return effectiveSubstatements().stream().filter(type::isInstance).findFirst().orElse(null);
+    }
+
+    // FIXME: rename to 'getFirstEffectiveStatement()'
+    protected final <S extends SchemaNode> S firstSchemaNode(final Class<S> type) {
+        return findFirstEffectiveSubstatement(type).orElse(null);
     }
 }
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2020 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,
@@ -9,12 +9,12 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.belongs_to;
 
 import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
 
-final class BelongsToEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, BelongsToStatement>
+abstract class AbstractBelongsToEffectiveStatement
+        extends AbstractDeclaredEffectiveStatement.DefaultArgument<String, BelongsToStatement>
         implements BelongsToEffectiveStatement {
-    BelongsToEffectiveStatementImpl(final StmtContext<String, BelongsToStatement, ?> ctx) {
-        super(ctx);
+    AbstractBelongsToEffectiveStatement(final BelongsToStatement declared) {
+        super(declared);
     }
 }
index d4f2ff8684f41c1a309147eb3195ba36e927adb5..6ee915e34e68598629152c9b6467136fad591616 100644 (file)
@@ -9,14 +9,16 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.belongs_to;
 
 import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.findFirstDeclaredSubstatement;
 
+import com.google.common.collect.ImmutableList;
 import java.util.Collection;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.InferenceAction;
@@ -30,8 +32,8 @@ import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToModuleContext;
 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleCtx;
 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNamespaceForBelongsTo;
 
-public final class BelongsToStatementSupport extends
-        AbstractStatementSupport<String, BelongsToStatement, EffectiveStatement<String, BelongsToStatement>> {
+public final class BelongsToStatementSupport
+        extends BaseStringStatementSupport<BelongsToStatement, BelongsToEffectiveStatement> {
     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
             SubstatementValidator.builder(YangStmtMapping.BELONGS_TO).addMandatory(YangStmtMapping.PREFIX).build();
     private static final BelongsToStatementSupport INSTANCE = new BelongsToStatementSupport();
@@ -50,26 +52,17 @@ public final class BelongsToStatementSupport extends
     }
 
     @Override
-    public BelongsToStatement createDeclared(
-            final StmtContext<String, BelongsToStatement, ?> ctx) {
+    public BelongsToStatement createDeclared(final StmtContext<String, BelongsToStatement, ?> ctx) {
         return new BelongsToStatementImpl(ctx);
     }
 
     @Override
-    public EffectiveStatement<String, BelongsToStatement> createEffective(
-            final StmtContext<String, BelongsToStatement, EffectiveStatement<String, BelongsToStatement>> ctx) {
-        return new BelongsToEffectiveStatementImpl(ctx);
+    public void onPreLinkageDeclared(final Mutable<String, BelongsToStatement, BelongsToEffectiveStatement> ctx) {
+        ctx.addRequiredSource(getSourceIdentifier(ctx));
     }
 
     @Override
-    public void onPreLinkageDeclared(final StmtContext.Mutable<String, BelongsToStatement,
-            EffectiveStatement<String, BelongsToStatement>> belongsToCtx) {
-        belongsToCtx.addRequiredSource(getSourceIdentifier(belongsToCtx));
-    }
-
-    @Override
-    public void onLinkageDeclared(final Mutable<String, BelongsToStatement,
-            EffectiveStatement<String, BelongsToStatement>> belongsToCtx) {
+    public void onLinkageDeclared(final Mutable<String, BelongsToStatement, BelongsToEffectiveStatement> belongsToCtx) {
         ModelActionBuilder belongsToAction = belongsToCtx.newInferenceAction(ModelProcessingPhase.SOURCE_LINKAGE);
 
         final SourceIdentifier belongsToSourceIdentifier = getSourceIdentifier(belongsToCtx);
@@ -98,8 +91,22 @@ public final class BelongsToStatementSupport extends
         });
     }
 
+    @Override
+    protected BelongsToEffectiveStatement createEffective(
+            final StmtContext<String, BelongsToStatement, BelongsToEffectiveStatement> ctx,
+            final BelongsToStatement declared, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        return new RegularBelongsToEffectiveStatement(declared, substatements);
+    }
+
+    @Override
+    protected BelongsToEffectiveStatement createEmptyEffective(
+            final StmtContext<String, BelongsToStatement, BelongsToEffectiveStatement> ctx,
+            final BelongsToStatement declared) {
+        return new EmptyBelongsToEffectiveStatement(declared);
+    }
+
     private static SourceIdentifier getSourceIdentifier(final StmtContext<String, BelongsToStatement,
-            EffectiveStatement<String, BelongsToStatement>> belongsToCtx) {
+            BelongsToEffectiveStatement> belongsToCtx) {
         return RevisionSourceIdentifier.create(belongsToCtx.coerceStatementArgument());
     }
 
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/belongs_to/EmptyBelongsToEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/belongs_to/EmptyBelongsToEffectiveStatement.java
new file mode 100644 (file)
index 0000000..3369719
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.belongs_to;
+
+import com.google.common.collect.ImmutableList;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
+
+final class EmptyBelongsToEffectiveStatement extends AbstractBelongsToEffectiveStatement {
+    EmptyBelongsToEffectiveStatement(final BelongsToStatement declared) {
+        super(declared);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return ImmutableList.of();
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/belongs_to/RegularBelongsToEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/belongs_to/RegularBelongsToEffectiveStatement.java
new file mode 100644 (file)
index 0000000..5a8d446
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.belongs_to;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
+
+final class RegularBelongsToEffectiveStatement extends AbstractBelongsToEffectiveStatement {
+    private final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements;
+
+    RegularBelongsToEffectiveStatement(final BelongsToStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        super(declared);
+        this.substatements = requireNonNull(substatements);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return substatements;
+    }
+}
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2020 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,
@@ -9,12 +9,12 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.contact;
 
 import org.opendaylight.yangtools.yang.model.api.stmt.ContactEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ContactStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
 
-final class ContactEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, ContactStatement>
+abstract class AbstractContactEffectiveStatement
+        extends AbstractDeclaredEffectiveStatement.DefaultArgument<String, ContactStatement>
         implements ContactEffectiveStatement {
-    ContactEffectiveStatementImpl(final StmtContext<String, ContactStatement, ?> ctx) {
-        super(ctx);
+    AbstractContactEffectiveStatement(final ContactStatement declared) {
+        super(declared);
     }
 }
index 201ab5dedeaaaa6ad717fe78c47822434dd8bf83..4d464adc8e94e8601e905906340ed1c3b68f182b 100644 (file)
@@ -7,15 +7,17 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.contact;
 
+import com.google.common.collect.ImmutableList;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ContactEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ContactStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 
 public final class ContactStatementSupport
-        extends AbstractStatementSupport<String, ContactStatement,EffectiveStatement<String, ContactStatement>> {
+        extends BaseStringStatementSupport<ContactStatement, ContactEffectiveStatement> {
     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
         YangStmtMapping.CONTACT).build();
     private static final ContactStatementSupport INSTANCE = new ContactStatementSupport();
@@ -39,13 +41,21 @@ public final class ContactStatementSupport
     }
 
     @Override
-    public EffectiveStatement<String, ContactStatement> createEffective(
-            final StmtContext<String, ContactStatement, EffectiveStatement<String, ContactStatement>> ctx) {
-        return new ContactEffectiveStatementImpl(ctx);
+    protected SubstatementValidator getSubstatementValidator() {
+        return SUBSTATEMENT_VALIDATOR;
     }
 
     @Override
-    protected SubstatementValidator getSubstatementValidator() {
-        return SUBSTATEMENT_VALIDATOR;
+    protected ContactEffectiveStatement createEffective(
+            final StmtContext<String, ContactStatement, ContactEffectiveStatement> ctx,
+            final ContactStatement declared, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        return new RegularContactEffectiveStatement(declared, substatements);
+    }
+
+    @Override
+    protected ContactEffectiveStatement createEmptyEffective(
+            final StmtContext<String, ContactStatement, ContactEffectiveStatement> ctx,
+            final ContactStatement declared) {
+        return new EmptyContactEffectiveStatement(declared);
     }
 }
\ No newline at end of file
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/contact/EmptyContactEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/contact/EmptyContactEffectiveStatement.java
new file mode 100644 (file)
index 0000000..43bef76
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.contact;
+
+import com.google.common.collect.ImmutableList;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ContactStatement;
+
+final class EmptyContactEffectiveStatement extends AbstractContactEffectiveStatement {
+    EmptyContactEffectiveStatement(final ContactStatement declared) {
+        super(declared);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return ImmutableList.of();
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/contact/RegularContactEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/contact/RegularContactEffectiveStatement.java
new file mode 100644 (file)
index 0000000..a6e7613
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.contact;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ContactStatement;
+
+final class RegularContactEffectiveStatement extends AbstractContactEffectiveStatement {
+    private final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements;
+
+    RegularContactEffectiveStatement(final ContactStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        super(declared);
+        this.substatements = requireNonNull(substatements);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return substatements;
+    }
+}
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2020 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,
@@ -9,12 +9,12 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.default_;
 
 import org.opendaylight.yangtools.yang.model.api.stmt.DefaultEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.DefaultStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
 
-final class DefaultEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, DefaultStatement>
+abstract class AbstractDefaultEffectiveStatement
+        extends AbstractDeclaredEffectiveStatement.DefaultArgument<String, DefaultStatement>
         implements DefaultEffectiveStatement {
-    DefaultEffectiveStatementImpl(final StmtContext<String, DefaultStatement, ?> ctx) {
-        super(ctx);
+    AbstractDefaultEffectiveStatement(final DefaultStatement declared) {
+        super(declared);
     }
-}
\ No newline at end of file
+}
index d0e42d157b85ccf970b4931c689001015939496e..a038934eb93e928859629cdbf3310d6d1e4b01ec 100644 (file)
@@ -7,15 +7,17 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.default_;
 
+import com.google.common.collect.ImmutableList;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DefaultEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.DefaultStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 
 public final class DefaultStatementSupport
-        extends AbstractStatementSupport<String, DefaultStatement, EffectiveStatement<String, DefaultStatement>> {
+        extends BaseStringStatementSupport<DefaultStatement, DefaultEffectiveStatement> {
     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
         YangStmtMapping.DEFAULT).build();
     private static final DefaultStatementSupport INSTANCE = new DefaultStatementSupport();
@@ -39,13 +41,21 @@ public final class DefaultStatementSupport
     }
 
     @Override
-    public EffectiveStatement<String, DefaultStatement> createEffective(
-            final StmtContext<String, DefaultStatement, EffectiveStatement<String, DefaultStatement>> ctx) {
-        return new DefaultEffectiveStatementImpl(ctx);
+    protected SubstatementValidator getSubstatementValidator() {
+        return SUBSTATEMENT_VALIDATOR;
     }
 
     @Override
-    protected SubstatementValidator getSubstatementValidator() {
-        return SUBSTATEMENT_VALIDATOR;
+    protected DefaultEffectiveStatement createEffective(
+            final StmtContext<String, DefaultStatement, DefaultEffectiveStatement> ctx,
+            final DefaultStatement declared, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        return new RegularDefaultEffectiveStatement(declared, substatements);
+    }
+
+    @Override
+    protected DefaultEffectiveStatement createEmptyEffective(
+            final StmtContext<String, DefaultStatement, DefaultEffectiveStatement> ctx,
+            final DefaultStatement declared) {
+        return new EmptyDefaultEffectiveStatement(declared);
     }
 }
\ No newline at end of file
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/default_/EmptyDefaultEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/default_/EmptyDefaultEffectiveStatement.java
new file mode 100644 (file)
index 0000000..bb6e55e
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.default_;
+
+import com.google.common.collect.ImmutableList;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DefaultStatement;
+
+final class EmptyDefaultEffectiveStatement extends AbstractDefaultEffectiveStatement {
+    EmptyDefaultEffectiveStatement(final DefaultStatement declared) {
+        super(declared);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return ImmutableList.of();
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/default_/RegularDefaultEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/default_/RegularDefaultEffectiveStatement.java
new file mode 100644 (file)
index 0000000..6f5db74
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.default_;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DefaultStatement;
+
+final class RegularDefaultEffectiveStatement extends AbstractDefaultEffectiveStatement {
+    private final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements;
+
+    RegularDefaultEffectiveStatement(final DefaultStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        super(declared);
+        this.substatements = requireNonNull(substatements);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return substatements;
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/description/AbstractDescriptionEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/description/AbstractDescriptionEffectiveStatement.java
new file mode 100644 (file)
index 0000000..f147c5d
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.description;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
+
+abstract class AbstractDescriptionEffectiveStatement
+        extends AbstractDeclaredEffectiveStatement.DefaultArgument<String, DescriptionStatement>
+        implements DescriptionEffectiveStatement {
+    AbstractDescriptionEffectiveStatement(final DescriptionStatement declared) {
+        super(declared);
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/description/DescriptionEffectiveStatementImpl.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/description/DescriptionEffectiveStatementImpl.java
deleted file mode 100644 (file)
index 102fa81..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (c) 2015 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.parser.rfc7950.stmt.description;
-
-import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-
-final class DescriptionEffectiveStatementImpl
-        extends DeclaredEffectiveStatementBase<String, DescriptionStatement> implements DescriptionEffectiveStatement {
-    DescriptionEffectiveStatementImpl(final StmtContext<String, DescriptionStatement, ?> ctx) {
-        super(ctx);
-    }
-}
index 501b9c4d65326315f359e767bbddd0b9a11f71bc..c7d7a65613d151e3ac126fc144e7b37183b96261 100644 (file)
@@ -7,15 +7,17 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.description;
 
+import com.google.common.collect.ImmutableList;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 
-public final class DescriptionStatementSupport extends AbstractStatementSupport<String, DescriptionStatement,
-        EffectiveStatement<String, DescriptionStatement>> {
+public final class DescriptionStatementSupport
+        extends BaseStringStatementSupport<DescriptionStatement, DescriptionEffectiveStatement> {
     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
         YangStmtMapping.DESCRIPTION).build();
     private static final DescriptionStatementSupport INSTANCE = new DescriptionStatementSupport();
@@ -39,13 +41,22 @@ public final class DescriptionStatementSupport extends AbstractStatementSupport<
     }
 
     @Override
-    public EffectiveStatement<String, DescriptionStatement> createEffective(
-            final StmtContext<String, DescriptionStatement, EffectiveStatement<String, DescriptionStatement>> ctx) {
-        return new DescriptionEffectiveStatementImpl(ctx);
+    protected SubstatementValidator getSubstatementValidator() {
+        return SUBSTATEMENT_VALIDATOR;
     }
 
     @Override
-    protected SubstatementValidator getSubstatementValidator() {
-        return SUBSTATEMENT_VALIDATOR;
+    protected DescriptionEffectiveStatement createEffective(
+            final StmtContext<String, DescriptionStatement, DescriptionEffectiveStatement> ctx,
+            final DescriptionStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        return new RegularDescriptionEffectiveStatement(declared, substatements);
+    }
+
+    @Override
+    protected DescriptionEffectiveStatement createEmptyEffective(
+            final StmtContext<String, DescriptionStatement, DescriptionEffectiveStatement> ctx,
+            final DescriptionStatement declared) {
+        return new EmptyDescriptionEffectiveStatement(declared);
     }
 }
\ No newline at end of file
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/description/EmptyDescriptionEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/description/EmptyDescriptionEffectiveStatement.java
new file mode 100644 (file)
index 0000000..eec36d0
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.description;
+
+import com.google.common.collect.ImmutableList;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+
+final class EmptyDescriptionEffectiveStatement extends AbstractDescriptionEffectiveStatement {
+    EmptyDescriptionEffectiveStatement(final DescriptionStatement declared) {
+        super(declared);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return ImmutableList.of();
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/description/RegularDescriptionEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/description/RegularDescriptionEffectiveStatement.java
new file mode 100644 (file)
index 0000000..5195157
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.description;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+
+final class RegularDescriptionEffectiveStatement extends AbstractDescriptionEffectiveStatement {
+    private final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements;
+
+    RegularDescriptionEffectiveStatement(final DescriptionStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        super(declared);
+        this.substatements = requireNonNull(substatements);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return substatements;
+    }
+}
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2020 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,
@@ -9,12 +9,12 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.error_app_tag;
 
 import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
 
-final class ErrorAppTagEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, ErrorAppTagStatement>
+abstract class AbstractErrorAppTagEffectiveStatement
+        extends AbstractDeclaredEffectiveStatement.DefaultArgument<String, ErrorAppTagStatement>
         implements ErrorAppTagEffectiveStatement {
-    ErrorAppTagEffectiveStatementImpl(final StmtContext<String, ErrorAppTagStatement, ?> ctx) {
-        super(ctx);
+    AbstractErrorAppTagEffectiveStatement(final ErrorAppTagStatement declared) {
+        super(declared);
     }
-}
\ No newline at end of file
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_app_tag/EmptyErrorAppTagEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_app_tag/EmptyErrorAppTagEffectiveStatement.java
new file mode 100644 (file)
index 0000000..10ee975
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.error_app_tag;
+
+import com.google.common.collect.ImmutableList;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
+
+final class EmptyErrorAppTagEffectiveStatement extends AbstractErrorAppTagEffectiveStatement {
+    EmptyErrorAppTagEffectiveStatement(final ErrorAppTagStatement declared) {
+        super(declared);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return ImmutableList.of();
+    }
+}
index db48d9ff6654767c6b44f3b873aeaf920830d69a..e5c0fe5763ca4c472bdbf78be68bf2d03d53b4c1 100644 (file)
@@ -7,15 +7,17 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.error_app_tag;
 
+import com.google.common.collect.ImmutableList;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 
-public final class ErrorAppTagStatementSupport extends
-        AbstractStatementSupport<String, ErrorAppTagStatement, EffectiveStatement<String, ErrorAppTagStatement>> {
+public final class ErrorAppTagStatementSupport
+        extends BaseStringStatementSupport<ErrorAppTagStatement, ErrorAppTagEffectiveStatement> {
     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
         YangStmtMapping.ERROR_APP_TAG).build();
     private static final ErrorAppTagStatementSupport INSTANCE = new ErrorAppTagStatementSupport();
@@ -34,19 +36,27 @@ public final class ErrorAppTagStatementSupport extends
     }
 
     @Override
-    public ErrorAppTagStatement createDeclared(
-            final StmtContext<String, ErrorAppTagStatement, ?> ctx) {
+    public ErrorAppTagStatement createDeclared(final StmtContext<String, ErrorAppTagStatement, ?> ctx) {
         return new ErrorAppTagStatementImpl(ctx);
     }
 
     @Override
-    public EffectiveStatement<String, ErrorAppTagStatement> createEffective(
-            final StmtContext<String, ErrorAppTagStatement, EffectiveStatement<String, ErrorAppTagStatement>> ctx) {
-        return new ErrorAppTagEffectiveStatementImpl(ctx);
+    protected SubstatementValidator getSubstatementValidator() {
+        return SUBSTATEMENT_VALIDATOR;
     }
 
     @Override
-    protected SubstatementValidator getSubstatementValidator() {
-        return SUBSTATEMENT_VALIDATOR;
+    protected ErrorAppTagEffectiveStatement createEffective(
+            final StmtContext<String, ErrorAppTagStatement, ErrorAppTagEffectiveStatement> ctx,
+            final ErrorAppTagStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        return new RegularErrorAppTagEffectiveStatement(declared, substatements);
+    }
+
+    @Override
+    protected ErrorAppTagEffectiveStatement createEmptyEffective(
+            final StmtContext<String, ErrorAppTagStatement, ErrorAppTagEffectiveStatement> ctx,
+            final ErrorAppTagStatement declared) {
+        return new EmptyErrorAppTagEffectiveStatement(declared);
     }
 }
\ No newline at end of file
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_app_tag/RegularErrorAppTagEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_app_tag/RegularErrorAppTagEffectiveStatement.java
new file mode 100644 (file)
index 0000000..3cf53df
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.error_app_tag;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
+
+final class RegularErrorAppTagEffectiveStatement extends AbstractErrorAppTagEffectiveStatement {
+    private final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements;
+
+    RegularErrorAppTagEffectiveStatement(final ErrorAppTagStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        super(declared);
+        this.substatements = requireNonNull(substatements);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return substatements;
+    }
+}
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2020 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,
@@ -9,12 +9,12 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.error_message;
 
 import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
 
-final class ErrorMessageEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, ErrorMessageStatement>
+abstract class AbstractErrorMessageEffectiveStatement
+        extends AbstractDeclaredEffectiveStatement.DefaultArgument<String, ErrorMessageStatement>
         implements ErrorMessageEffectiveStatement {
-    ErrorMessageEffectiveStatementImpl(final StmtContext<String, ErrorMessageStatement, ?> ctx) {
-        super(ctx);
+    AbstractErrorMessageEffectiveStatement(final ErrorMessageStatement declared) {
+        super(declared);
     }
-}
\ No newline at end of file
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_message/EmptyErrorMessageEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_message/EmptyErrorMessageEffectiveStatement.java
new file mode 100644 (file)
index 0000000..15c88e4
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.error_message;
+
+import com.google.common.collect.ImmutableList;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
+
+final class EmptyErrorMessageEffectiveStatement extends AbstractErrorMessageEffectiveStatement {
+    EmptyErrorMessageEffectiveStatement(final ErrorMessageStatement declared) {
+        super(declared);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return ImmutableList.of();
+    }
+}
index fa74543cba8fd5f13a189358e127b5d22f8742a0..7e561c148010c35b9e06ff3e1df67dcf17ce380a 100644 (file)
@@ -7,18 +7,19 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.error_message;
 
+import com.google.common.collect.ImmutableList;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 
-public final class ErrorMessageStatementSupport extends
-        AbstractStatementSupport<String, ErrorMessageStatement, EffectiveStatement<String, ErrorMessageStatement>> {
-    private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(YangStmtMapping
-        .ERROR_MESSAGE)
-        .build();
+public final class ErrorMessageStatementSupport
+        extends BaseStringStatementSupport<ErrorMessageStatement, ErrorMessageEffectiveStatement> {
+    private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
+            SubstatementValidator.builder(YangStmtMapping.ERROR_MESSAGE).build();
     private static final ErrorMessageStatementSupport INSTANCE = new ErrorMessageStatementSupport();
 
     private ErrorMessageStatementSupport() {
@@ -40,14 +41,22 @@ public final class ErrorMessageStatementSupport extends
     }
 
     @Override
-    public EffectiveStatement<String, ErrorMessageStatement> createEffective(
-            final StmtContext<String, ErrorMessageStatement,
-            EffectiveStatement<String, ErrorMessageStatement>> ctx) {
-        return new ErrorMessageEffectiveStatementImpl(ctx);
+    protected SubstatementValidator getSubstatementValidator() {
+        return SUBSTATEMENT_VALIDATOR;
     }
 
     @Override
-    protected SubstatementValidator getSubstatementValidator() {
-        return SUBSTATEMENT_VALIDATOR;
+    protected ErrorMessageEffectiveStatement createEffective(
+            final StmtContext<String, ErrorMessageStatement, ErrorMessageEffectiveStatement> ctx,
+            final ErrorMessageStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        return new RegularErrorMessageEffectiveStatement(declared, substatements);
+    }
+
+    @Override
+    protected ErrorMessageEffectiveStatement createEmptyEffective(
+            final StmtContext<String, ErrorMessageStatement, ErrorMessageEffectiveStatement> ctx,
+            final ErrorMessageStatement declared) {
+        return new EmptyErrorMessageEffectiveStatement(declared);
     }
-}
\ No newline at end of file
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_message/RegularErrorMessageEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/error_message/RegularErrorMessageEffectiveStatement.java
new file mode 100644 (file)
index 0000000..b825a03
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.error_message;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
+
+final class RegularErrorMessageEffectiveStatement extends AbstractErrorMessageEffectiveStatement {
+    private final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements;
+
+    RegularErrorMessageEffectiveStatement(final ErrorMessageStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        super(declared);
+        this.substatements = requireNonNull(substatements);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return substatements;
+    }
+}
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2020 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,
@@ -9,12 +9,12 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ordered_by;
 
 import org.opendaylight.yangtools.yang.model.api.stmt.OrderedByEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.OrderedByStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
 
-final class OrderedByEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, OrderedByStatement>
+abstract class AbstractOrderedByEffectiveStatement
+        extends AbstractDeclaredEffectiveStatement.DefaultArgument<String, OrderedByStatement>
         implements OrderedByEffectiveStatement {
-    OrderedByEffectiveStatementImpl(final StmtContext<String, OrderedByStatement, ?> ctx) {
-        super(ctx);
+    AbstractOrderedByEffectiveStatement(final OrderedByStatement declared) {
+        super(declared);
     }
-}
\ No newline at end of file
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/ordered_by/EmptyOrderedByEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/ordered_by/EmptyOrderedByEffectiveStatement.java
new file mode 100644 (file)
index 0000000..8eeb1d6
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.ordered_by;
+
+import com.google.common.collect.ImmutableList;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.OrderedByStatement;
+
+final class EmptyOrderedByEffectiveStatement extends AbstractOrderedByEffectiveStatement {
+    EmptyOrderedByEffectiveStatement(final OrderedByStatement declared) {
+        super(declared);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return ImmutableList.of();
+    }
+}
index 87513e2d308975d4d133198bd49ed14e3044c1b5..aeefa3bccc8ee5f6a0b6adce993614a7b5769bdd 100644 (file)
@@ -7,18 +7,19 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ordered_by;
 
+import com.google.common.collect.ImmutableList;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.OrderedByEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.OrderedByStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 
 public final class OrderedByStatementSupport
-        extends AbstractStatementSupport<String, OrderedByStatement, EffectiveStatement<String, OrderedByStatement>> {
-    private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
-        YangStmtMapping.ORDERED_BY)
-        .build();
+        extends BaseStringStatementSupport<OrderedByStatement, OrderedByEffectiveStatement> {
+    private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
+            SubstatementValidator.builder(YangStmtMapping.ORDERED_BY).build();
     private static final OrderedByStatementSupport INSTANCE = new OrderedByStatementSupport();
 
     private OrderedByStatementSupport() {
@@ -40,14 +41,23 @@ public final class OrderedByStatementSupport
     }
 
     @Override
-    public EffectiveStatement<String, OrderedByStatement> createEffective(
-            final StmtContext<String, OrderedByStatement, EffectiveStatement<String, OrderedByStatement>> ctx) {
-        return new OrderedByEffectiveStatementImpl(ctx);
+    protected SubstatementValidator getSubstatementValidator() {
+        return SUBSTATEMENT_VALIDATOR;
     }
 
     @Override
-    protected SubstatementValidator getSubstatementValidator() {
-        return SUBSTATEMENT_VALIDATOR;
+    protected OrderedByEffectiveStatement createEffective(
+            final StmtContext<String, OrderedByStatement, OrderedByEffectiveStatement> ctx,
+            final OrderedByStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        return new RegularOrderedByEffectiveStatement(declared, substatements);
+    }
+
+    @Override
+    protected OrderedByEffectiveStatement createEmptyEffective(
+            final StmtContext<String, OrderedByStatement, OrderedByEffectiveStatement> ctx,
+            final OrderedByStatement declared) {
+        return new EmptyOrderedByEffectiveStatement(declared);
     }
 
     @Override
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/ordered_by/RegularOrderedByEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/ordered_by/RegularOrderedByEffectiveStatement.java
new file mode 100644 (file)
index 0000000..3d67c14
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.ordered_by;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.OrderedByStatement;
+
+final class RegularOrderedByEffectiveStatement extends AbstractOrderedByEffectiveStatement {
+    private final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements;
+
+    RegularOrderedByEffectiveStatement(final OrderedByStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        super(declared);
+        this.substatements = requireNonNull(substatements);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return substatements;
+    }
+}
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2020 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,
@@ -9,12 +9,12 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.prefix;
 
 import org.opendaylight.yangtools.yang.model.api.stmt.PrefixEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
 
-final class PrefixEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, PrefixStatement>
+abstract class AbstractPrefixEffectiveStatement
+        extends AbstractDeclaredEffectiveStatement.DefaultArgument<String, PrefixStatement>
         implements PrefixEffectiveStatement {
-    PrefixEffectiveStatementImpl(final StmtContext<String, PrefixStatement, ?> ctx) {
-        super(ctx);
+    AbstractPrefixEffectiveStatement(final PrefixStatement declared) {
+        super(declared);
     }
 }
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/prefix/EmptyPrefixEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/prefix/EmptyPrefixEffectiveStatement.java
new file mode 100644 (file)
index 0000000..62aa3f7
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.prefix;
+
+import com.google.common.collect.ImmutableList;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
+
+final class EmptyPrefixEffectiveStatement extends AbstractPrefixEffectiveStatement {
+    EmptyPrefixEffectiveStatement(final PrefixStatement declared) {
+        super(declared);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return ImmutableList.of();
+    }
+}
index 0eed9afa46c4f42a82d1b54d3630e0379ae29130..09b8d59073a7cf664b68722d7f213e2a281d71fd 100644 (file)
@@ -7,18 +7,19 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.prefix;
 
+import com.google.common.collect.ImmutableList;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.PrefixEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 
 public final class PrefixStatementSupport
-    extends AbstractStatementSupport<String, PrefixStatement, EffectiveStatement<String, PrefixStatement>> {
-    private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(YangStmtMapping
-        .PREFIX)
-        .build();
+        extends BaseStringStatementSupport<PrefixStatement, PrefixEffectiveStatement> {
+    private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
+            SubstatementValidator.builder(YangStmtMapping.PREFIX).build();
     private static final PrefixStatementSupport INSTANCE = new PrefixStatementSupport();
 
     private PrefixStatementSupport() {
@@ -40,13 +41,20 @@ public final class PrefixStatementSupport
     }
 
     @Override
-    public EffectiveStatement<String,PrefixStatement> createEffective(
-            final StmtContext<String, PrefixStatement, EffectiveStatement<String, PrefixStatement>> ctx) {
-        return new PrefixEffectiveStatementImpl(ctx);
+    protected SubstatementValidator getSubstatementValidator() {
+        return SUBSTATEMENT_VALIDATOR;
     }
 
     @Override
-    protected SubstatementValidator getSubstatementValidator() {
-        return SUBSTATEMENT_VALIDATOR;
+    protected PrefixEffectiveStatement createEffective(
+            final StmtContext<String, PrefixStatement, PrefixEffectiveStatement> ctx, final PrefixStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        return new RegularPrefixEffectiveStatement(declared, substatements);
+    }
+
+    @Override
+    protected PrefixEffectiveStatement createEmptyEffective(
+            final StmtContext<String, PrefixStatement, PrefixEffectiveStatement> ctx, final PrefixStatement declared) {
+        return new EmptyPrefixEffectiveStatement(declared);
     }
-}
\ No newline at end of file
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/prefix/RegularPrefixEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/prefix/RegularPrefixEffectiveStatement.java
new file mode 100644 (file)
index 0000000..a131aa6
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.prefix;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
+
+final class RegularPrefixEffectiveStatement extends AbstractPrefixEffectiveStatement {
+    private final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements;
+
+    RegularPrefixEffectiveStatement(final PrefixStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        super(declared);
+        this.substatements = requireNonNull(substatements);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return substatements;
+    }
+}
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2020 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,
@@ -9,12 +9,12 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.presence;
 
 import org.opendaylight.yangtools.yang.model.api.stmt.PresenceEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.PresenceStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
 
-final class PresenceEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, PresenceStatement>
+abstract class AbstractPresenceEffectiveStatement
+        extends AbstractDeclaredEffectiveStatement.DefaultArgument<String, PresenceStatement>
         implements PresenceEffectiveStatement {
-    PresenceEffectiveStatementImpl(final StmtContext<String, PresenceStatement, ?> ctx) {
-        super(ctx);
+    AbstractPresenceEffectiveStatement(final PresenceStatement declared) {
+        super(declared);
     }
 }
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/presence/EmptyPresenceEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/presence/EmptyPresenceEffectiveStatement.java
new file mode 100644 (file)
index 0000000..536ebc4
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.presence;
+
+import com.google.common.collect.ImmutableList;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.PresenceStatement;
+
+final class EmptyPresenceEffectiveStatement extends AbstractPresenceEffectiveStatement {
+    EmptyPresenceEffectiveStatement(final PresenceStatement declared) {
+        super(declared);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return ImmutableList.of();
+    }
+}
index 72f77a47a7af26e2fb2d595e46b61722461ddedc..2fd845bf93b261d5f9c42db33948228883fe5c0d 100644 (file)
@@ -7,18 +7,19 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.presence;
 
+import com.google.common.collect.ImmutableList;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.PresenceEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.PresenceStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 
 public final class PresenceStatementSupport
-        extends AbstractStatementSupport<String, PresenceStatement, EffectiveStatement<String, PresenceStatement>> {
-    private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(YangStmtMapping
-        .PRESENCE)
-        .build();
+        extends BaseStringStatementSupport<PresenceStatement, PresenceEffectiveStatement> {
+    private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
+            SubstatementValidator.builder(YangStmtMapping.PRESENCE).build();
     private static final PresenceStatementSupport INSTANCE = new PresenceStatementSupport();
 
     private PresenceStatementSupport() {
@@ -40,13 +41,22 @@ public final class PresenceStatementSupport
     }
 
     @Override
-    public EffectiveStatement<String, PresenceStatement> createEffective(
-            final StmtContext<String, PresenceStatement, EffectiveStatement<String, PresenceStatement>> ctx) {
-        return new PresenceEffectiveStatementImpl(ctx);
+    protected SubstatementValidator getSubstatementValidator() {
+        return SUBSTATEMENT_VALIDATOR;
     }
 
     @Override
-    protected SubstatementValidator getSubstatementValidator() {
-        return SUBSTATEMENT_VALIDATOR;
+    protected PresenceEffectiveStatement createEffective(
+            final StmtContext<String, PresenceStatement, PresenceEffectiveStatement> ctx,
+            final PresenceStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        return new RegularPresenceEffectiveStatement(declared, substatements);
+    }
+
+    @Override
+    protected PresenceEffectiveStatement createEmptyEffective(
+            final StmtContext<String, PresenceStatement, PresenceEffectiveStatement> ctx,
+            final PresenceStatement declared) {
+        return new EmptyPresenceEffectiveStatement(declared);
     }
 }
\ No newline at end of file
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/presence/RegularPresenceEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/presence/RegularPresenceEffectiveStatement.java
new file mode 100644 (file)
index 0000000..fa045b2
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.presence;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.PresenceStatement;
+
+final class RegularPresenceEffectiveStatement extends AbstractPresenceEffectiveStatement {
+    private final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements;
+
+    RegularPresenceEffectiveStatement(final PresenceStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        super(declared);
+        this.substatements = requireNonNull(substatements);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return substatements;
+    }
+}
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2020 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,
@@ -9,12 +9,12 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.reference;
 
 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
 
-final class ReferenceEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, ReferenceStatement>
+abstract class AbstractReferenceEffectiveStatement
+        extends AbstractDeclaredEffectiveStatement.DefaultArgument<String, ReferenceStatement>
         implements ReferenceEffectiveStatement {
-    ReferenceEffectiveStatementImpl(final StmtContext<String, ReferenceStatement, ?> ctx) {
-        super(ctx);
+    AbstractReferenceEffectiveStatement(final ReferenceStatement declared) {
+        super(declared);
     }
 }
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/reference/EmptyReferenceEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/reference/EmptyReferenceEffectiveStatement.java
new file mode 100644 (file)
index 0000000..fa2bc6e
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.reference;
+
+import com.google.common.collect.ImmutableList;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+
+final class EmptyReferenceEffectiveStatement extends AbstractReferenceEffectiveStatement {
+    EmptyReferenceEffectiveStatement(final ReferenceStatement declared) {
+        super(declared);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return ImmutableList.of();
+    }
+}
index f502a065e9bda57e8e17a4471c9bc8bd287d92d4..e73ef12f605bf8b8f086f56abb137416a4a6c542 100644 (file)
@@ -7,15 +7,17 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.reference;
 
+import com.google.common.collect.ImmutableList;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 
-public final class ReferenceStatementSupport extends AbstractStatementSupport<String, ReferenceStatement,
-        EffectiveStatement<String, ReferenceStatement>> {
+public final class ReferenceStatementSupport
+        extends BaseStringStatementSupport<ReferenceStatement, ReferenceEffectiveStatement> {
     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
         YangStmtMapping.REFERENCE)
         .build();
@@ -40,13 +42,22 @@ public final class ReferenceStatementSupport extends AbstractStatementSupport<St
     }
 
     @Override
-    public EffectiveStatement<String, ReferenceStatement> createEffective(
-            final StmtContext<String, ReferenceStatement, EffectiveStatement<String, ReferenceStatement>> ctx) {
-        return new ReferenceEffectiveStatementImpl(ctx);
+    protected SubstatementValidator getSubstatementValidator() {
+        return SUBSTATEMENT_VALIDATOR;
     }
 
     @Override
-    protected SubstatementValidator getSubstatementValidator() {
-        return SUBSTATEMENT_VALIDATOR;
+    protected ReferenceEffectiveStatement createEffective(
+            final StmtContext<String, ReferenceStatement, ReferenceEffectiveStatement> ctx,
+            final ReferenceStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        return new RegularReferenceEffectiveStatement(declared, substatements);
+    }
+
+    @Override
+    protected ReferenceEffectiveStatement createEmptyEffective(
+            final StmtContext<String, ReferenceStatement, ReferenceEffectiveStatement> ctx,
+            final ReferenceStatement declared) {
+        return new EmptyReferenceEffectiveStatement(declared);
     }
 }
\ No newline at end of file
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/reference/RegularReferenceEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/reference/RegularReferenceEffectiveStatement.java
new file mode 100644 (file)
index 0000000..3ef9ab7
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.reference;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+
+final class RegularReferenceEffectiveStatement extends AbstractReferenceEffectiveStatement {
+    private final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements;
+
+    RegularReferenceEffectiveStatement(final ReferenceStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        super(declared);
+        this.substatements = requireNonNull(substatements);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return substatements;
+    }
+}
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2020 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,
@@ -9,12 +9,12 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.units;
 
 import org.opendaylight.yangtools.yang.model.api.stmt.UnitsEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnitsStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
 
-final class UnitsEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, UnitsStatement>
+abstract class AbstractUnitsEffectiveStatement
+        extends AbstractDeclaredEffectiveStatement.DefaultArgument<String, UnitsStatement>
         implements UnitsEffectiveStatement {
-    UnitsEffectiveStatementImpl(final StmtContext<String, UnitsStatement, ?> ctx) {
-        super(ctx);
+    AbstractUnitsEffectiveStatement(final UnitsStatement declared) {
+        super(declared);
     }
 }
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/units/EmptyUnitsEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/units/EmptyUnitsEffectiveStatement.java
new file mode 100644 (file)
index 0000000..a52bc3f
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.units;
+
+import com.google.common.collect.ImmutableList;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.UnitsStatement;
+
+final class EmptyUnitsEffectiveStatement extends AbstractUnitsEffectiveStatement {
+    EmptyUnitsEffectiveStatement(final UnitsStatement declared) {
+        super(declared);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return ImmutableList.of();
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/units/RegularUnitsEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/units/RegularUnitsEffectiveStatement.java
new file mode 100644 (file)
index 0000000..284cc59
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020 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.parser.rfc7950.stmt.units;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.UnitsStatement;
+
+final class RegularUnitsEffectiveStatement extends AbstractUnitsEffectiveStatement {
+    private final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements;
+
+    RegularUnitsEffectiveStatement(final UnitsStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        super(declared);
+        this.substatements = requireNonNull(substatements);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return substatements;
+    }
+}
index 7cd5cb01159cf6059f46746ec823bb35177386d6..fcf4914498b6fafb670f345645d4fa72d0ad0cc9 100644 (file)
@@ -7,15 +7,17 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.units;
 
+import com.google.common.collect.ImmutableList;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.UnitsEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnitsStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 
 public final class UnitsStatementSupport
-        extends AbstractStatementSupport<String, UnitsStatement, EffectiveStatement<String, UnitsStatement>> {
+        extends BaseStringStatementSupport<UnitsStatement, UnitsEffectiveStatement> {
     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
         YangStmtMapping.UNITS)
         .build();
@@ -35,19 +37,26 @@ public final class UnitsStatementSupport
     }
 
     @Override
-    public UnitsStatement createDeclared(
-            final StmtContext<String, UnitsStatement, ?> ctx) {
+    public UnitsStatement createDeclared(final StmtContext<String, UnitsStatement, ?> ctx) {
         return new UnitsStatementImpl(ctx);
     }
 
     @Override
-    public EffectiveStatement<String, UnitsStatement> createEffective(
-            final StmtContext<String, UnitsStatement, EffectiveStatement<String, UnitsStatement>> ctx) {
-        return new UnitsEffectiveStatementImpl(ctx);
+    protected SubstatementValidator getSubstatementValidator() {
+        return SUBSTATEMENT_VALIDATOR;
     }
 
     @Override
-    protected SubstatementValidator getSubstatementValidator() {
-        return SUBSTATEMENT_VALIDATOR;
+    protected UnitsEffectiveStatement createEffective(
+            final StmtContext<String, UnitsStatement, UnitsEffectiveStatement> ctx,
+            final UnitsStatement declared, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        return new RegularUnitsEffectiveStatement(declared, substatements);
+    }
+
+    @Override
+    protected UnitsEffectiveStatement createEmptyEffective(
+            final StmtContext<String, UnitsStatement, UnitsEffectiveStatement> ctx,
+            final UnitsStatement declared) {
+        return new EmptyUnitsEffectiveStatement(declared);
     }
 }
\ No newline at end of file