Add AbstractBooleanDeclaredStatement/BaseBooleanStatementSupport 87/87187/3
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 27 Jan 2020 21:11:17 +0000 (22:11 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 27 Jan 2020 23:44:56 +0000 (00:44 +0100)
mandatory/config/require-instance/yin-element statements share the
same shape of being stateless boolean holders. Add an explicit
base class, making sure all common declarations end up referencing
the same 4 objects.

JIRA: YANGTOOLS-1065
Change-Id: I0c423ad1fc34c2a4c55c92d246830880a4c8bf9b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
33 files changed:
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractBooleanDeclaredStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/BaseBooleanStatementSupport.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/AbstractConfigEffectiveStatement.java [moved from yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/ConfigEffectiveStatementImpl.java with 52% similarity]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/AbstractConfigStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/ConfigStatementImpl.java [deleted file]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/ConfigStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/EmptyConfigEffectiveStatement.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/EmptyConfigStatement.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/RegularConfigEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/RegularConfigStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/AbstractMandatoryEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/AbstractMandatoryStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/EmptyMandatoryEffectiveStatement.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/EmptyMandatoryStatement.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/MandatoryEffectiveStatementImpl.java [deleted file]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/MandatoryStatementImpl.java [deleted file]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/MandatoryStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/RegularMandatoryEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/RegularMandatoryStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/AbstractRequireInstanceEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/AbstractRequireInstanceStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/EmptyRequireInstanceEffectiveStatement.java [moved from yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/RequireInstanceStatementImpl.java with 54% similarity]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/EmptyRequireInstanceStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/RegularRequireInstanceEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/RegularRequireInstanceStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/RequireInstanceStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/AbstractYinElementEffectiveStatement.java [moved from yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/YinElementEffectiveStatementImpl.java with 53% similarity]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/AbstractYinElementStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/EmptyYinElementEffectiveStatement.java [moved from yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/YinElementStatementImpl.java with 55% similarity]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/EmptyYinElementStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/RegularYinElementEffectiveStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/RegularYinElementStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/YinElementStatementSupport.java

diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractBooleanDeclaredStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractBooleanDeclaredStatement.java
new file mode 100644 (file)
index 0000000..367a790
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+@Beta
+public abstract class AbstractBooleanDeclaredStatement extends AbstractDeclaredStatement<Boolean> {
+    private final @NonNull Boolean argument;
+
+    protected AbstractBooleanDeclaredStatement(final Boolean argument) {
+        this.argument = requireNonNull(argument);
+    }
+
+    @Override
+    public final @NonNull Boolean argument() {
+        return argument;
+    }
+
+    @Override
+    public final String rawArgument() {
+        return argument.toString();
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/BaseBooleanStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/BaseBooleanStatementSupport.java
new file mode 100644 (file)
index 0000000..cddf937
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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.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.StmtContext;
+
+/**
+ * Specialization of {@link BaseStatementSupport} for Boolean statement arguments.
+ *
+ * @param <D> Declared Statement representation
+ * @param <E> Effective Statement representation
+ */
+@Beta
+public abstract class BaseBooleanStatementSupport<D extends DeclaredStatement<Boolean>,
+        E extends EffectiveStatement<Boolean, D>> extends BaseStatementSupport<Boolean, D, E> {
+    private final @NonNull E emptyEffectiveFalse;
+    private final @NonNull E emptyEffectiveTrue;
+    private final @NonNull D emptyDeclaredFalse;
+    private final @NonNull D emptyDeclaredTrue;
+
+    protected BaseBooleanStatementSupport(final StatementDefinition publicDefinition,
+            final E emptyEffectiveFalse, final E emptyEffectiveTrue) {
+        super(publicDefinition);
+        this.emptyEffectiveFalse = requireNonNull(emptyEffectiveFalse);
+        this.emptyEffectiveTrue = requireNonNull(emptyEffectiveTrue);
+        emptyDeclaredFalse = requireNonNull(emptyEffectiveFalse.getDeclared());
+        emptyDeclaredTrue = requireNonNull(emptyEffectiveTrue.getDeclared());
+    }
+
+    @Override
+    public final Boolean parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
+        return ArgumentUtils.parseBoolean(ctx, value);
+    }
+
+    @Override
+    public final String internArgument(final String rawArgument) {
+        return ArgumentUtils.internBoolean(rawArgument);
+    }
+
+    @Override
+    protected final D createEmptyDeclared(final StmtContext<Boolean, D, ?> ctx) {
+        return ctx.coerceStatementArgument() ? emptyDeclaredTrue : emptyDeclaredFalse;
+    }
+
+    @Override
+    protected final E createEmptyEffective(final StmtContext<Boolean, D, E> ctx, final D declared) {
+        if (emptyDeclaredTrue.equals(declared)) {
+            return emptyEffectiveTrue;
+        } else if (emptyDeclaredFalse.equals(declared)) {
+            return emptyEffectiveFalse;
+        } else {
+            return createEmptyEffective(declared);
+        }
+    }
+
+    protected abstract @NonNull E createEmptyEffective(@NonNull D declared);
+}
@@ -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.config;
 
 import org.opendaylight.yangtools.yang.model.api.stmt.ConfigEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
-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;
 
-public final class ConfigEffectiveStatementImpl extends DeclaredEffectiveStatementBase<Boolean, ConfigStatement>
+abstract class AbstractConfigEffectiveStatement
+        extends AbstractDeclaredEffectiveStatement.DefaultArgument<Boolean, ConfigStatement>
         implements ConfigEffectiveStatement {
-    public ConfigEffectiveStatementImpl(final StmtContext<Boolean, ConfigStatement, ?> ctx) {
-        super(ctx);
+    AbstractConfigEffectiveStatement(final ConfigStatement declared) {
+        super(declared);
     }
 }
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/AbstractConfigStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/AbstractConfigStatement.java
new file mode 100644 (file)
index 0000000..15d0c65
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.config;
+
+import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractBooleanDeclaredStatement;
+
+abstract class AbstractConfigStatement extends AbstractBooleanDeclaredStatement implements ConfigStatement {
+    AbstractConfigStatement(final Boolean argument) {
+        super(argument);
+    }
+
+    @Override
+    public StatementDefinition statementDefinition() {
+        return YangStmtMapping.CONFIG;
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/ConfigStatementImpl.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/ConfigStatementImpl.java
deleted file mode 100644 (file)
index 30895ac..0000000
+++ /dev/null
@@ -1,18 +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.config;
-
-import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-
-final class ConfigStatementImpl extends AbstractDeclaredStatement<Boolean> implements ConfigStatement {
-    ConfigStatementImpl(final StmtContext<Boolean, ConfigStatement, ?> context) {
-        super(context);
-    }
-}
index dc4079d8b85a82811e6d4bfd78b7f73dd263bc94..143196f029c56f0224596da103cd213fead5973a 100644 (file)
@@ -7,22 +7,25 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.config;
 
+import com.google.common.collect.ImmutableList;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+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.stmt.ConfigEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ArgumentUtils;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseBooleanStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 
 public final class ConfigStatementSupport
-        extends AbstractStatementSupport<Boolean, ConfigStatement, ConfigEffectiveStatement> {
+        extends BaseBooleanStatementSupport<ConfigStatement, ConfigEffectiveStatement> {
     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
         YangStmtMapping.CONFIG).build();
     private static final ConfigStatementSupport INSTANCE = new ConfigStatementSupport();
 
     private ConfigStatementSupport() {
-        super(YangStmtMapping.CONFIG);
+        super(YangStmtMapping.CONFIG, new EmptyConfigEffectiveStatement(new EmptyConfigStatement(Boolean.FALSE)),
+            new EmptyConfigEffectiveStatement(new EmptyConfigStatement(Boolean.TRUE)));
     }
 
     public static ConfigStatementSupport getInstance() {
@@ -30,41 +33,25 @@ public final class ConfigStatementSupport
     }
 
     @Override
-    public Boolean parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
-        return ArgumentUtils.parseBoolean(ctx, value);
-    }
-
-    @Override
-    public ConfigStatement createDeclared(final StmtContext<Boolean, ConfigStatement, ?> ctx) {
-        final ConfigStatement ret = new ConfigStatementImpl(ctx);
-
-        if (EmptyConfigStatement.FALSE.equals(ret)) {
-            return EmptyConfigStatement.FALSE;
-        } else if (EmptyConfigStatement.TRUE.equals(ret)) {
-            return EmptyConfigStatement.TRUE;
-        } else {
-            return ret;
-        }
+    protected SubstatementValidator getSubstatementValidator() {
+        return SUBSTATEMENT_VALIDATOR;
     }
 
     @Override
-    public ConfigEffectiveStatement createEffective(
-            final StmtContext<Boolean, ConfigStatement, ConfigEffectiveStatement> ctx) {
-        final ConfigEffectiveStatement ret = new ConfigEffectiveStatementImpl(ctx);
-        final ConfigStatement declared = ret.getDeclared();
-        if (declared instanceof EmptyConfigStatement && ret.effectiveSubstatements().isEmpty()) {
-            return ((EmptyConfigStatement)declared).toEffective();
-        }
-        return ret;
+    protected ConfigStatement createDeclared(final StmtContext<Boolean, ConfigStatement, ?> ctx,
+            final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+        return new RegularConfigStatement(ctx.coerceStatementArgument(), substatements);
     }
 
     @Override
-    public String internArgument(final String rawArgument) {
-        return ArgumentUtils.internBoolean(rawArgument);
+    protected ConfigEffectiveStatement createEffective(
+            final StmtContext<Boolean, ConfigStatement, ConfigEffectiveStatement> ctx,
+            final ConfigStatement declared, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        return new RegularConfigEffectiveStatement(declared, substatements);
     }
 
     @Override
-    protected SubstatementValidator getSubstatementValidator() {
-        return SUBSTATEMENT_VALIDATOR;
+    protected EmptyConfigEffectiveStatement createEmptyEffective(final ConfigStatement declared) {
+        return new EmptyConfigEffectiveStatement(declared);
     }
 }
\ No newline at end of file
index 4d74b79270b92b981bdd1d5f93c7b7739fcb9b66..2691374e951e8bac5993a0be729f3fde2ee05448 100644 (file)
@@ -7,68 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.config;
 
-import com.google.common.collect.ImmutableList;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Optional;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
-import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
-import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
-import org.opendaylight.yangtools.yang.model.api.stmt.ConfigEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
 
-abstract class EmptyConfigEffectiveStatement implements ConfigEffectiveStatement {
-    static final EmptyConfigEffectiveStatement FALSE = new EmptyConfigEffectiveStatement() {
-        @Override
-        public ConfigStatement getDeclared() {
-            return EmptyConfigStatement.FALSE;
-        }
-    };
-
-    static final EmptyConfigEffectiveStatement TRUE = new EmptyConfigEffectiveStatement() {
-        @Override
-        public ConfigStatement getDeclared() {
-            return EmptyConfigStatement.TRUE;
-        }
-    };
-
-    private EmptyConfigEffectiveStatement() {
-        // Hidden
-    }
-
-    @Override
-    public final StatementDefinition statementDefinition() {
-        return getDeclared().statementDefinition();
-    }
-
-    @Override
-    public final Boolean argument() {
-        return getDeclared().argument();
-    }
-
-    @Override
-    public final StatementSource getStatementSource() {
-        return getDeclared().getStatementSource();
+final class EmptyConfigEffectiveStatement extends AbstractConfigEffectiveStatement {
+    EmptyConfigEffectiveStatement(final ConfigStatement declared) {
+        super(declared);
     }
-
-    @Override
-    public final <K, V, N extends IdentifierNamespace<K, V>> Optional<? extends V> get(final Class<N> namespace,
-            final K identifier) {
-        throw new UnsupportedOperationException("Not implemented yet.");
-    }
-
-    @Override
-    public final <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAll(final Class<N> namespace) {
-        throw new UnsupportedOperationException("Not implemented yet.");
-    }
-
-    @Override
-    public final Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
-        return ImmutableList.of();
-    }
-
-    @Override
-    public abstract @NonNull ConfigStatement getDeclared();
 }
index 6af25e24c8db623956fd689843c5a542ed275a4a..bfec337044f68c05fe128cce8d089dce0010e34c 100644 (file)
@@ -7,85 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.config;
 
-import com.google.common.collect.ImmutableList;
-import java.util.Collection;
-import java.util.Objects;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
-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;
-import org.opendaylight.yangtools.yang.model.api.stmt.ConfigEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
-
-abstract class EmptyConfigStatement implements ConfigStatement {
-    static final @NonNull ConfigStatement FALSE = new EmptyConfigStatement() {
-        @Override
-        public Boolean argument() {
-            return Boolean.FALSE;
-        }
-
-        @Override
-        ConfigEffectiveStatement toEffective() {
-            return EmptyConfigEffectiveStatement.FALSE;
-        }
-    };
-
-    static final @NonNull ConfigStatement TRUE = new EmptyConfigStatement() {
-        @Override
-        public Boolean argument() {
-            return Boolean.TRUE;
-        }
-
-        @Override
-        ConfigEffectiveStatement toEffective() {
-            return EmptyConfigEffectiveStatement.TRUE;
-        }
-    };
-
-    abstract ConfigEffectiveStatement toEffective();
-
-    @Override
-    public final Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
-        return ImmutableList.of();
-    }
-
-    @Override
-    public final StatementDefinition statementDefinition() {
-        return YangStmtMapping.CONFIG;
-    }
-
-    @Override
-    public final String rawArgument() {
-        return Boolean.toString(getValue());
-    }
-
-    @Override
-    public final StatementSource getStatementSource() {
-        return StatementSource.DECLARATION;
-    }
-
-    @Override
-    public final int hashCode() {
-        return Objects.hash(statementDefinition(), getStatementSource(), argument(), rawArgument(),
-            declaredSubstatements(), getValue());
-    }
-
-    @Override
-    public final boolean equals(final Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!(obj instanceof ConfigStatement)) {
-            return false;
-        }
-
-        final ConfigStatement other = (ConfigStatement) obj;
-
-        return getValue() == other.getValue() && argument().equals(other.argument())
-                && rawArgument().equals(other.rawArgument())
-                && statementDefinition().equals(other.statementDefinition())
-                && getStatementSource().equals(other.getStatementSource())
-                && declaredSubstatements().equals(other.declaredSubstatements());
+final class EmptyConfigStatement extends AbstractConfigStatement {
+    EmptyConfigStatement(final Boolean argument) {
+        super(argument);
     }
 }
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/RegularConfigEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/RegularConfigEffectiveStatement.java
new file mode 100644 (file)
index 0000000..6209cae
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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.config;
+
+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.ConfigStatement;
+
+final class RegularConfigEffectiveStatement extends AbstractConfigEffectiveStatement {
+    private final @NonNull Object substatements;
+
+    RegularConfigEffectiveStatement(final ConfigStatement declared,
+        final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        super(declared);
+        this.substatements = maskList(substatements);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return unmaskList(substatements);
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/RegularConfigStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/config/RegularConfigStatement.java
new file mode 100644 (file)
index 0000000..0f79164
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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.config;
+
+import com.google.common.collect.ImmutableList;
+import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+
+final class RegularConfigStatement extends AbstractConfigStatement {
+    private final @NonNull Object substatements;
+
+    RegularConfigStatement(final Boolean argument, final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+        super(argument);
+        this.substatements = maskList(substatements);
+    }
+
+    @Override
+    public Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
+        return unmaskList(substatements);
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/AbstractMandatoryEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/AbstractMandatoryEffectiveStatement.java
new file mode 100644 (file)
index 0000000..db8d390
--- /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.mandatory;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
+
+abstract class AbstractMandatoryEffectiveStatement
+        extends AbstractDeclaredEffectiveStatement.DefaultArgument<Boolean, MandatoryStatement>
+        implements MandatoryEffectiveStatement {
+    AbstractMandatoryEffectiveStatement(final MandatoryStatement declared) {
+        super(declared);
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/AbstractMandatoryStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/AbstractMandatoryStatement.java
new file mode 100644 (file)
index 0000000..ef4b080
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.mandatory;
+
+import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractBooleanDeclaredStatement;
+
+abstract class AbstractMandatoryStatement extends AbstractBooleanDeclaredStatement implements MandatoryStatement {
+    AbstractMandatoryStatement(final Boolean argument) {
+        super(argument);
+    }
+
+    @Override
+    public StatementDefinition statementDefinition() {
+        return YangStmtMapping.MANDATORY;
+    }
+}
index 448c96ca539e0e93d1d2c489da211b28b6ca5809..e79c7b5dc811d96e7c1ec8ac57ad56cb2100fa58 100644 (file)
@@ -7,64 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.mandatory;
 
-import com.google.common.collect.ImmutableList;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Optional;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
-import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
-import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
-import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
 
-abstract class EmptyMandatoryEffectiveStatement implements MandatoryEffectiveStatement {
-    static final EmptyMandatoryEffectiveStatement FALSE = new EmptyMandatoryEffectiveStatement() {
-        @Override
-        public MandatoryStatement getDeclared() {
-            return EmptyMandatoryStatement.FALSE;
-        }
-    };
-
-    static final EmptyMandatoryEffectiveStatement TRUE = new EmptyMandatoryEffectiveStatement() {
-        @Override
-        public MandatoryStatement getDeclared() {
-            return EmptyMandatoryStatement.TRUE;
-        }
-    };
-
-    @Override
-    public final StatementDefinition statementDefinition() {
-        return getDeclared().statementDefinition();
-    }
-
-    @Override
-    public final Boolean argument() {
-        return getDeclared().argument();
+final class EmptyMandatoryEffectiveStatement extends AbstractMandatoryEffectiveStatement {
+    EmptyMandatoryEffectiveStatement(final MandatoryStatement declared) {
+        super(declared);
     }
-
-    @Override
-    public final StatementSource getStatementSource() {
-        return getDeclared().getStatementSource();
-    }
-
-    @Override
-    public final <K, V, N extends IdentifierNamespace<K, V>> Optional<? extends V> get(final Class<N> namespace,
-            final K identifier) {
-        throw new UnsupportedOperationException("Not implemented yet.");
-    }
-
-    @Override
-    public final <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAll(final Class<N> namespace) {
-        throw new UnsupportedOperationException("Not implemented yet.");
-    }
-
-    @Override
-    public final Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
-        return ImmutableList.of();
-    }
-
-    @Override
-    public abstract @NonNull MandatoryStatement getDeclared();
 }
index ae7915a0d52f2893bba9856d3bb680235df02044..2b1d1e92b47a6f91a46b049e0a02797811c30bd4 100644 (file)
@@ -7,85 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.mandatory;
 
-import com.google.common.collect.ImmutableList;
-import java.util.Collection;
-import java.util.Objects;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
-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.model.api.meta.StatementSource;
-import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
-
-abstract class EmptyMandatoryStatement implements MandatoryStatement {
-    static final @NonNull MandatoryStatement FALSE = new EmptyMandatoryStatement() {
-        @Override
-        public Boolean argument() {
-            return Boolean.FALSE;
-        }
-
-        @Override
-        EffectiveStatement<Boolean, MandatoryStatement> toEffective() {
-            return EmptyMandatoryEffectiveStatement.FALSE;
-        }
-    };
-
-    static final @NonNull MandatoryStatement TRUE = new EmptyMandatoryStatement() {
-        @Override
-        public Boolean argument() {
-            return Boolean.TRUE;
-        }
-
-        @Override
-        EffectiveStatement<Boolean, MandatoryStatement> toEffective() {
-            return EmptyMandatoryEffectiveStatement.TRUE;
-        }
-    };
-
-    abstract EffectiveStatement<Boolean, MandatoryStatement> toEffective();
-
-    @Override
-    public final Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
-        return ImmutableList.of();
-    }
-
-    @Override
-    public final StatementDefinition statementDefinition() {
-        return YangStmtMapping.MANDATORY;
-    }
-
-    @Override
-    public final String rawArgument() {
-        return getValue().toString();
-    }
-
-    @Override
-    public final StatementSource getStatementSource() {
-        return StatementSource.DECLARATION;
-    }
-
-    @Override
-    public final int hashCode() {
-        return Objects.hash(statementDefinition(), getStatementSource(), argument(),
-            rawArgument(), declaredSubstatements(), getValue());
-    }
-
-    @Override
-    public final boolean equals(final Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!(obj instanceof MandatoryStatement)) {
-            return false;
-        }
-
-        final MandatoryStatement other = (MandatoryStatement) obj;
-        return argument().equals(other.argument())
-                && rawArgument().equals(other.rawArgument())
-                && getValue().equals(other.getValue())
-                && statementDefinition().equals(other.statementDefinition())
-                && getStatementSource().equals(other.getStatementSource())
-                && declaredSubstatements().equals(other.declaredSubstatements());
+final class EmptyMandatoryStatement extends AbstractMandatoryStatement {
+    EmptyMandatoryStatement(final Boolean argument) {
+        super(argument);
     }
 }
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/MandatoryEffectiveStatementImpl.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/MandatoryEffectiveStatementImpl.java
deleted file mode 100644 (file)
index 428a0c0..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.mandatory;
-
-import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-
-final class MandatoryEffectiveStatementImpl extends DeclaredEffectiveStatementBase<Boolean, MandatoryStatement>
-    implements MandatoryEffectiveStatement {
-    MandatoryEffectiveStatementImpl(final StmtContext<Boolean, MandatoryStatement, ?> ctx) {
-        super(ctx);
-    }
-}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/MandatoryStatementImpl.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/MandatoryStatementImpl.java
deleted file mode 100644 (file)
index 68be40f..0000000
+++ /dev/null
@@ -1,18 +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.mandatory;
-
-import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-
-final class MandatoryStatementImpl extends AbstractDeclaredStatement<Boolean> implements MandatoryStatement {
-    MandatoryStatementImpl(final StmtContext<Boolean, MandatoryStatement, ?> context) {
-        super(context);
-    }
-}
index 5564ff329dc31a247be9bf623da80ff7c0a3d60a..17d22f19f604a193f6cfe30fd8d4b55d065a9bfd 100644 (file)
@@ -7,22 +7,26 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.mandatory;
 
+import com.google.common.collect.ImmutableList;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+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.stmt.MandatoryEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ArgumentUtils;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseBooleanStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 
 public final class MandatoryStatementSupport extends
-        AbstractStatementSupport<Boolean, MandatoryStatement, EffectiveStatement<Boolean, MandatoryStatement>> {
+        BaseBooleanStatementSupport<MandatoryStatement, MandatoryEffectiveStatement> {
     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
         YangStmtMapping.MANDATORY).build();
     private static final MandatoryStatementSupport INSTANCE = new MandatoryStatementSupport();
 
     private MandatoryStatementSupport() {
-        super(YangStmtMapping.MANDATORY);
+        super(YangStmtMapping.MANDATORY,
+            new EmptyMandatoryEffectiveStatement(new EmptyMandatoryStatement(Boolean.FALSE)),
+            new EmptyMandatoryEffectiveStatement(new EmptyMandatoryStatement(Boolean.TRUE)));
     }
 
     public static MandatoryStatementSupport getInstance() {
@@ -30,40 +34,25 @@ public final class MandatoryStatementSupport extends
     }
 
     @Override
-    public Boolean parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
-        return ArgumentUtils.parseBoolean(ctx, value);
-    }
-
-    @Override
-    public MandatoryStatement createDeclared(final StmtContext<Boolean, MandatoryStatement, ?> ctx) {
-        final MandatoryStatement ret = new MandatoryStatementImpl(ctx);
-        if (EmptyMandatoryStatement.FALSE.equals(ret)) {
-            return EmptyMandatoryStatement.FALSE;
-        } else if (EmptyMandatoryStatement.TRUE.equals(ret)) {
-            return EmptyMandatoryStatement.TRUE;
-        } else {
-            return ret;
-        }
+    protected SubstatementValidator getSubstatementValidator() {
+        return SUBSTATEMENT_VALIDATOR;
     }
 
     @Override
-    public EffectiveStatement<Boolean, MandatoryStatement> createEffective(
-            final StmtContext<Boolean, MandatoryStatement, EffectiveStatement<Boolean, MandatoryStatement>> ctx) {
-        final EffectiveStatement<Boolean, MandatoryStatement> ret = new MandatoryEffectiveStatementImpl(ctx);
-        final MandatoryStatement declared = ret.getDeclared();
-        if (declared instanceof EmptyMandatoryStatement && ret.effectiveSubstatements().isEmpty()) {
-            return ((EmptyMandatoryStatement)declared).toEffective();
-        }
-        return ret;
+    protected MandatoryStatement createDeclared(final StmtContext<Boolean, MandatoryStatement, ?> ctx,
+            final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+        return new RegularMandatoryStatement(ctx.coerceStatementArgument(), substatements);
     }
 
     @Override
-    public String internArgument(final String rawArgument) {
-        return ArgumentUtils.internBoolean(rawArgument);
+    protected MandatoryEffectiveStatement createEffective(
+            final StmtContext<Boolean, MandatoryStatement, MandatoryEffectiveStatement> ctx,
+            final MandatoryStatement declared, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        return new RegularMandatoryEffectiveStatement(declared, substatements);
     }
 
     @Override
-    protected SubstatementValidator getSubstatementValidator() {
-        return SUBSTATEMENT_VALIDATOR;
+    protected MandatoryEffectiveStatement createEmptyEffective(final MandatoryStatement declared) {
+        return new EmptyMandatoryEffectiveStatement(declared);
     }
-}
\ No newline at end of file
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/RegularMandatoryEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/RegularMandatoryEffectiveStatement.java
new file mode 100644 (file)
index 0000000..d41bfb9
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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.mandatory;
+
+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.MandatoryStatement;
+
+final class RegularMandatoryEffectiveStatement extends AbstractMandatoryEffectiveStatement {
+    private final @NonNull Object substatements;
+
+    RegularMandatoryEffectiveStatement(final MandatoryStatement declared,
+        final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        super(declared);
+        this.substatements = maskList(substatements);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return unmaskList(substatements);
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/RegularMandatoryStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/mandatory/RegularMandatoryStatement.java
new file mode 100644 (file)
index 0000000..a63e455
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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.mandatory;
+
+import com.google.common.collect.ImmutableList;
+import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+
+final class RegularMandatoryStatement extends AbstractMandatoryStatement {
+    private final @NonNull Object substatements;
+
+    RegularMandatoryStatement(final Boolean argument,
+            final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+        super(argument);
+        this.substatements = maskList(substatements);
+    }
+
+    @Override
+    public Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
+        return unmaskList(substatements);
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/AbstractRequireInstanceEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/AbstractRequireInstanceEffectiveStatement.java
new file mode 100644 (file)
index 0000000..2e26aba
--- /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.require_instance;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceStatement;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
+
+abstract class AbstractRequireInstanceEffectiveStatement
+        extends AbstractDeclaredEffectiveStatement.DefaultArgument<Boolean, RequireInstanceStatement>
+        implements RequireInstanceEffectiveStatement {
+    AbstractRequireInstanceEffectiveStatement(final RequireInstanceStatement declared) {
+        super(declared);
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/AbstractRequireInstanceStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/AbstractRequireInstanceStatement.java
new file mode 100644 (file)
index 0000000..00cd197
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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.require_instance;
+
+import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceStatement;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractBooleanDeclaredStatement;
+
+abstract class AbstractRequireInstanceStatement extends AbstractBooleanDeclaredStatement
+        implements RequireInstanceStatement {
+    AbstractRequireInstanceStatement(final Boolean argument) {
+        super(argument);
+    }
+
+    @Override
+    public StatementDefinition statementDefinition() {
+        return YangStmtMapping.REQUIRE_INSTANCE;
+    }
+}
@@ -8,12 +8,9 @@
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.require_instance;
 
 import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
-final class RequireInstanceStatementImpl extends AbstractDeclaredStatement<Boolean>
-        implements RequireInstanceStatement {
-    RequireInstanceStatementImpl(final StmtContext<Boolean, RequireInstanceStatement, ?> context) {
-        super(context);
+final class EmptyRequireInstanceEffectiveStatement extends AbstractRequireInstanceEffectiveStatement {
+    EmptyRequireInstanceEffectiveStatement(final RequireInstanceStatement declared) {
+        super(declared);
     }
 }
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/EmptyRequireInstanceStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/EmptyRequireInstanceStatement.java
new file mode 100644 (file)
index 0000000..b4a0ec3
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * 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.require_instance;
+
+final class EmptyRequireInstanceStatement extends AbstractRequireInstanceStatement {
+    EmptyRequireInstanceStatement(final Boolean argument) {
+        super(argument);
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/RegularRequireInstanceEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/RegularRequireInstanceEffectiveStatement.java
new file mode 100644 (file)
index 0000000..8694b6c
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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.require_instance;
+
+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.RequireInstanceStatement;
+
+final class RegularRequireInstanceEffectiveStatement extends AbstractRequireInstanceEffectiveStatement {
+    private final @NonNull Object substatements;
+
+    RegularRequireInstanceEffectiveStatement(final RequireInstanceStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        super(declared);
+        this.substatements = maskList(substatements);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return unmaskList(substatements);
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/RegularRequireInstanceStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/require_instance/RegularRequireInstanceStatement.java
new file mode 100644 (file)
index 0000000..ced1682
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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.require_instance;
+
+import com.google.common.collect.ImmutableList;
+import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+
+final class RegularRequireInstanceStatement extends AbstractRequireInstanceStatement {
+    private final @NonNull Object substatements;
+
+    RegularRequireInstanceStatement(final Boolean argument,
+            final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+        super(argument);
+        this.substatements = maskList(substatements);
+    }
+
+    @Override
+    public Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
+        return unmaskList(substatements);
+    }
+}
index cc6c909d872dc7151ecaa9604289da5fe4b983b9..8a947ade99c10b4cdc010c9dfebdecee7bd181ee 100644 (file)
@@ -7,22 +7,27 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.require_instance;
 
+import com.google.common.collect.ImmutableList;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+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.stmt.RequireInstanceEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ArgumentUtils;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseBooleanStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 
 public final class RequireInstanceStatementSupport
-        extends AbstractStatementSupport<Boolean, RequireInstanceStatement, RequireInstanceEffectiveStatement> {
+        extends BaseBooleanStatementSupport<RequireInstanceStatement, RequireInstanceEffectiveStatement> {
     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
         YangStmtMapping.REQUIRE_INSTANCE).build();
     private static final RequireInstanceStatementSupport INSTANCE = new RequireInstanceStatementSupport();
 
+
     private RequireInstanceStatementSupport() {
-        super(YangStmtMapping.REQUIRE_INSTANCE);
+        super(YangStmtMapping.REQUIRE_INSTANCE,
+            new EmptyRequireInstanceEffectiveStatement(new EmptyRequireInstanceStatement(Boolean.FALSE)),
+            new EmptyRequireInstanceEffectiveStatement(new EmptyRequireInstanceStatement(Boolean.TRUE)));
     }
 
     public static RequireInstanceStatementSupport getInstance() {
@@ -30,28 +35,26 @@ public final class RequireInstanceStatementSupport
     }
 
     @Override
-    public Boolean parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
-        return ArgumentUtils.parseBoolean(ctx, value);
-    }
-
-    @Override
-    public RequireInstanceStatement createDeclared(final StmtContext<Boolean, RequireInstanceStatement, ?> ctx) {
-        return new RequireInstanceStatementImpl(ctx);
+    protected SubstatementValidator getSubstatementValidator() {
+        return SUBSTATEMENT_VALIDATOR;
     }
 
     @Override
-    public RequireInstanceEffectiveStatement createEffective(
-            final StmtContext<Boolean, RequireInstanceStatement, RequireInstanceEffectiveStatement> ctx) {
-        return new RequireInstanceEffectiveStatementImpl(ctx);
+    protected RequireInstanceStatement createDeclared(final StmtContext<Boolean, RequireInstanceStatement, ?> ctx,
+            final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+        return new RegularRequireInstanceStatement(ctx.coerceStatementArgument(), substatements);
     }
 
     @Override
-    public String internArgument(final String rawArgument) {
-        return ArgumentUtils.internBoolean(rawArgument);
+    protected RequireInstanceEffectiveStatement createEffective(
+            final StmtContext<Boolean, RequireInstanceStatement, RequireInstanceEffectiveStatement> ctx,
+            final RequireInstanceStatement declared,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        return new RegularRequireInstanceEffectiveStatement(declared, substatements);
     }
 
     @Override
-    protected SubstatementValidator getSubstatementValidator() {
-        return SUBSTATEMENT_VALIDATOR;
+    protected EmptyRequireInstanceEffectiveStatement createEmptyEffective(final RequireInstanceStatement declared) {
+        return new EmptyRequireInstanceEffectiveStatement(declared);
     }
 }
\ No newline at end of file
@@ -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.yin_element;
 
 import org.opendaylight.yangtools.yang.model.api.stmt.YinElementEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
-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 YinElementEffectiveStatementImpl extends DeclaredEffectiveStatementBase<Boolean, YinElementStatement>
+abstract class AbstractYinElementEffectiveStatement
+        extends AbstractDeclaredEffectiveStatement.DefaultArgument<Boolean, YinElementStatement>
         implements YinElementEffectiveStatement {
-    YinElementEffectiveStatementImpl(final StmtContext<Boolean, YinElementStatement, ?> ctx) {
-        super(ctx);
+    AbstractYinElementEffectiveStatement(final YinElementStatement declared) {
+        super(declared);
     }
 }
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/AbstractYinElementStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/AbstractYinElementStatement.java
new file mode 100644 (file)
index 0000000..d1dda50
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.yin_element;
+
+import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractBooleanDeclaredStatement;
+
+abstract class AbstractYinElementStatement extends AbstractBooleanDeclaredStatement implements YinElementStatement {
+    AbstractYinElementStatement(final Boolean argument) {
+        super(argument);
+    }
+
+    @Override
+    public StatementDefinition statementDefinition() {
+        return YangStmtMapping.YIN_ELEMENT;
+    }
+}
@@ -8,11 +8,9 @@
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.yin_element;
 
 import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
-final class YinElementStatementImpl extends AbstractDeclaredStatement<Boolean> implements YinElementStatement {
-    YinElementStatementImpl(final StmtContext<Boolean, YinElementStatement, ?> context) {
-        super(context);
+final class EmptyYinElementEffectiveStatement extends AbstractYinElementEffectiveStatement {
+    EmptyYinElementEffectiveStatement(final YinElementStatement declared) {
+        super(declared);
     }
 }
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/EmptyYinElementStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/EmptyYinElementStatement.java
new file mode 100644 (file)
index 0000000..76de8ca
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * 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.yin_element;
+
+final class EmptyYinElementStatement extends AbstractYinElementStatement {
+    EmptyYinElementStatement(final Boolean argument) {
+        super(argument);
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/RegularYinElementEffectiveStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/RegularYinElementEffectiveStatement.java
new file mode 100644 (file)
index 0000000..7ffc12c
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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.yin_element;
+
+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.YinElementStatement;
+
+final class RegularYinElementEffectiveStatement extends AbstractYinElementEffectiveStatement {
+    private final @NonNull Object substatements;
+
+    RegularYinElementEffectiveStatement(final YinElementStatement declared,
+        final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        super(declared);
+        this.substatements = maskList(substatements);
+    }
+
+    @Override
+    public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return unmaskList(substatements);
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/RegularYinElementStatement.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yin_element/RegularYinElementStatement.java
new file mode 100644 (file)
index 0000000..e612c26
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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.yin_element;
+
+import com.google.common.collect.ImmutableList;
+import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+
+final class RegularYinElementStatement extends AbstractYinElementStatement {
+    private final @NonNull Object substatements;
+
+    RegularYinElementStatement(final Boolean argument,
+            final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+        super(argument);
+        this.substatements = maskList(substatements);
+    }
+
+    @Override
+    public Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
+        return unmaskList(substatements);
+    }
+}
index c8a19616754d445ebcb77d8b7b6e98f60844109e..303f0daf7f916cf5c08a8c1d5c12411aa1451757 100644 (file)
@@ -7,22 +7,26 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.yin_element;
 
+import com.google.common.collect.ImmutableList;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+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.stmt.YinElementEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ArgumentUtils;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseBooleanStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 
 public final class YinElementStatementSupport
-        extends AbstractStatementSupport<Boolean, YinElementStatement, YinElementEffectiveStatement> {
+        extends BaseBooleanStatementSupport<YinElementStatement, YinElementEffectiveStatement> {
     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
         YangStmtMapping.YIN_ELEMENT).build();
     private static final YinElementStatementSupport INSTANCE = new YinElementStatementSupport();
 
     private YinElementStatementSupport() {
-        super(YangStmtMapping.YIN_ELEMENT);
+        super(YangStmtMapping.YIN_ELEMENT,
+            new EmptyYinElementEffectiveStatement(new EmptyYinElementStatement(Boolean.FALSE)),
+            new EmptyYinElementEffectiveStatement(new EmptyYinElementStatement(Boolean.TRUE)));
     }
 
     public static YinElementStatementSupport getInstance() {
@@ -30,28 +34,25 @@ public final class YinElementStatementSupport
     }
 
     @Override
-    public Boolean parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
-        return ArgumentUtils.parseBoolean(ctx, value);
-    }
-
-    @Override
-    public YinElementStatement createDeclared(final StmtContext<Boolean, YinElementStatement, ?> ctx) {
-        return new YinElementStatementImpl(ctx);
+    protected SubstatementValidator getSubstatementValidator() {
+        return SUBSTATEMENT_VALIDATOR;
     }
 
     @Override
-    public YinElementEffectiveStatement createEffective(
-            final StmtContext<Boolean, YinElementStatement, YinElementEffectiveStatement> ctx) {
-        return new YinElementEffectiveStatementImpl(ctx);
+    protected YinElementStatement createDeclared(final StmtContext<Boolean, YinElementStatement, ?> ctx,
+            final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+        return new RegularYinElementStatement(ctx.coerceStatementArgument(), substatements);
     }
 
     @Override
-    public String internArgument(final String rawArgument) {
-        return ArgumentUtils.internBoolean(rawArgument);
+    protected YinElementEffectiveStatement createEffective(
+            final StmtContext<Boolean, YinElementStatement, YinElementEffectiveStatement> ctx,
+            final YinElementStatement declared, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        return new RegularYinElementEffectiveStatement(declared, substatements);
     }
 
     @Override
-    protected SubstatementValidator getSubstatementValidator() {
-        return SUBSTATEMENT_VALIDATOR;
+    protected YinElementEffectiveStatement createEmptyEffective(final YinElementStatement declared) {
+        return new EmptyYinElementEffectiveStatement(declared);
     }
-}
\ No newline at end of file
+}