package org.opendaylight.yangtools.rfc6241.parser;
import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.rfc6241.model.api.GetFilterElementAttributesEffectiveStatement;
import org.opendaylight.yangtools.rfc6241.model.api.GetFilterElementAttributesSchemaNode;
import org.opendaylight.yangtools.rfc6241.model.api.GetFilterElementAttributesStatement;
import org.opendaylight.yangtools.rfc6241.model.api.NetconfStatements;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.SchemaNodeDefaults;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
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.parser.rfc7950.stmt.AbstractDeclaredStatement.WithoutArgument.WithSubstatements;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseVoidStatementSupport;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.UnknownEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractVoidStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SchemaPathSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
import org.slf4j.LoggerFactory;
@Beta
-public final class GetFilterElementAttributesStatementSupport
- extends AbstractVoidStatementSupport<GetFilterElementAttributesStatement,
- GetFilterElementAttributesEffectiveStatement> {
-
- private static final class Declared extends AbstractDeclaredStatement<Void>
- implements GetFilterElementAttributesStatement {
- Declared(final StmtContext<Void, ?, ?> context) {
- super(context);
- }
+public final class GetFilterElementAttributesStatementSupport extends BaseVoidStatementSupport<
+ GetFilterElementAttributesStatement, GetFilterElementAttributesEffectiveStatement> {
- @Override
- public Void getArgument() {
- return null;
+ private static final class Declared extends WithSubstatements implements GetFilterElementAttributesStatement {
+ static final @NonNull Declared EMPTY = new Declared(ImmutableList.of());
+
+ Declared(final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ super(substatements);
}
}
private static final class Effective
extends UnknownEffectiveStatementBase<Void, GetFilterElementAttributesStatement>
implements GetFilterElementAttributesEffectiveStatement, GetFilterElementAttributesSchemaNode {
+ private final @Nullable SchemaPath path;
- private final SchemaPath path;
-
- Effective(final StmtContext<Void, GetFilterElementAttributesStatement, ?> ctx) {
- super(ctx);
- path = ctx.coerceParentContext().getSchemaPath().get().createChild(
- ctx.getPublicDefinition().getStatementName());
+ Effective(final Current<Void, GetFilterElementAttributesStatement> stmt,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ super(stmt, substatements);
+ path = SchemaPathSupport.wrap(stmt.getEffectiveParent().getSchemaPath()
+ .createChild(stmt.publicDefinition().getStatementName()));
}
@Override
}
@Override
+ @Deprecated
public SchemaPath getPath() {
- return path;
+ return SchemaNodeDefaults.throwUnsupportedIfNull(this, path);
+ }
+
+ @Override
+ public GetFilterElementAttributesEffectiveStatement asEffectiveStatement() {
+ return this;
}
}
}
@Override
- public GetFilterElementAttributesStatement createDeclared(
- final StmtContext<Void, GetFilterElementAttributesStatement, ?> ctx) {
- return new Declared(ctx);
+ public void onFullDefinitionDeclared(final Mutable<Void, GetFilterElementAttributesStatement,
+ GetFilterElementAttributesEffectiveStatement> stmt) {
+ super.onFullDefinitionDeclared(stmt);
+ stmt.setIsSupportedToBuildEffective(computeSupported(stmt));
}
@Override
- public GetFilterElementAttributesEffectiveStatement createEffective(final StmtContext<Void,
- GetFilterElementAttributesStatement, GetFilterElementAttributesEffectiveStatement> ctx) {
- return new Effective(ctx);
+ protected SubstatementValidator getSubstatementValidator() {
+ return validator;
}
@Override
- protected SubstatementValidator getSubstatementValidator() {
- return validator;
+ protected GetFilterElementAttributesStatement createDeclared(
+ final StmtContext<Void, GetFilterElementAttributesStatement, ?> ctx,
+ final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ return new Declared(substatements);
}
@Override
- public void onFullDefinitionDeclared(final Mutable<Void, GetFilterElementAttributesStatement,
- GetFilterElementAttributesEffectiveStatement> stmt) {
- super.onFullDefinitionDeclared(stmt);
- stmt.setIsSupportedToBuildEffective(computeSupported(stmt));
+ protected GetFilterElementAttributesStatement createEmptyDeclared(
+ final StmtContext<Void, GetFilterElementAttributesStatement, ?> ctx) {
+ return Declared.EMPTY;
+ }
+
+ @Override
+ protected GetFilterElementAttributesEffectiveStatement createEffective(
+ final Current<Void, GetFilterElementAttributesStatement> stmt,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ return new Effective(stmt, substatements);
}
private static boolean computeSupported(final StmtContext<?, ?, ?> stmt) {
LOG.debug("No parent, ignoring get-filter-element-attributes statement");
return false;
}
- if (parent.getPublicDefinition() != YangStmtMapping.ANYXML) {
+ if (parent.publicDefinition() != YangStmtMapping.ANYXML) {
LOG.debug("Parent is not an anyxml node, ignoring get-filter-element-attributes statement");
return false;
}
- if (!"filter".equals(parent.rawStatementArgument())) {
+ if (!"filter".equals(parent.rawArgument())) {
LOG.debug("Parent is not named 'filter', ignoring get-filter-element-attributes statement");
return false;
}
LOG.debug("No grandparent, ignoring get-filter-element-attributes statement");
return false;
}
- if (grandParent.getPublicDefinition() != YangStmtMapping.INPUT) {
+ if (grandParent.publicDefinition() != YangStmtMapping.INPUT) {
LOG.debug("Grandparent is not an input node, ignoring get-filter-element-attributes statement");
return false;
}
LOG.debug("No grandparent, ignoring get-filter-element-attributes statement");
return false;
}
- if (greatGrandParent.getPublicDefinition() != YangStmtMapping.RPC) {
+ if (greatGrandParent.publicDefinition() != YangStmtMapping.RPC) {
LOG.debug("Grandparent is not an RPC node, ignoring get-filter-element-attributes statement");
return false;
}
- switch (greatGrandParent.rawStatementArgument()) {
+ switch (greatGrandParent.getRawArgument()) {
case "get":
case "get-config":
return true;