2 * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.rfc6241.parser;
10 import com.google.common.annotations.Beta;
11 import com.google.common.collect.ImmutableList;
12 import org.opendaylight.yangtools.rfc6241.model.api.GetFilterElementAttributesEffectiveStatement;
13 import org.opendaylight.yangtools.rfc6241.model.api.GetFilterElementAttributesStatement;
14 import org.opendaylight.yangtools.rfc6241.model.api.NetconfStatements;
15 import org.opendaylight.yangtools.yang.common.Empty;
16 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
17 import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference;
18 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
19 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
20 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractEmptyStatementSupport;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
23 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
25 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
30 public final class GetFilterElementAttributesStatementSupport extends AbstractEmptyStatementSupport<
31 GetFilterElementAttributesStatement, GetFilterElementAttributesEffectiveStatement> {
32 private static final Logger LOG = LoggerFactory.getLogger(GetFilterElementAttributesStatementSupport.class);
33 private static final SubstatementValidator VALIDATOR =
34 SubstatementValidator.builder(NetconfStatements.GET_FILTER_ELEMENT_ATTRIBUTES).build();
36 public GetFilterElementAttributesStatementSupport(final YangParserConfiguration config) {
37 super(NetconfStatements.GET_FILTER_ELEMENT_ATTRIBUTES, StatementPolicy.reject(), config, VALIDATOR);
41 public void onFullDefinitionDeclared(final Mutable<Empty, GetFilterElementAttributesStatement,
42 GetFilterElementAttributesEffectiveStatement> stmt) {
43 super.onFullDefinitionDeclared(stmt);
44 stmt.setIsSupportedToBuildEffective(computeSupported(stmt));
48 protected GetFilterElementAttributesStatement createDeclared(
49 final StmtContext<Empty, GetFilterElementAttributesStatement, ?> ctx,
50 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
51 return substatements.isEmpty() ? GetFilterElementAttributesStatementImpl.EMPTY
52 : new GetFilterElementAttributesStatementImpl(substatements);
56 protected GetFilterElementAttributesStatement attachDeclarationReference(
57 final GetFilterElementAttributesStatement stmt, final DeclarationReference reference) {
58 return new RefGetFilterElementAttributesStatement(stmt, reference);
62 protected GetFilterElementAttributesEffectiveStatement createEffective(
63 final Current<Empty, GetFilterElementAttributesStatement> stmt,
64 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
65 return new GetFilterElementAttributesEffectiveStatementImpl(stmt, substatements);
68 private static boolean computeSupported(final StmtContext<?, ?, ?> stmt) {
69 final StmtContext<?, ?, ?> parent = stmt.getParentContext();
71 LOG.debug("No parent, ignoring get-filter-element-attributes statement");
74 if (parent.publicDefinition() != YangStmtMapping.ANYXML) {
75 LOG.debug("Parent is not an anyxml node, ignoring get-filter-element-attributes statement");
78 if (!"filter".equals(parent.rawArgument())) {
79 LOG.debug("Parent is not named 'filter', ignoring get-filter-element-attributes statement");
83 final StmtContext<?, ?, ?> grandParent = parent.getParentContext();
84 if (grandParent == null) {
85 LOG.debug("No grandparent, ignoring get-filter-element-attributes statement");
88 if (grandParent.publicDefinition() != YangStmtMapping.INPUT) {
89 LOG.debug("Grandparent is not an input node, ignoring get-filter-element-attributes statement");
93 final StmtContext<?, ?, ?> greatGrandParent = grandParent.getParentContext();
94 if (greatGrandParent == null) {
95 LOG.debug("No grandparent, ignoring get-filter-element-attributes statement");
98 if (greatGrandParent.publicDefinition() != YangStmtMapping.RPC) {
99 LOG.debug("Grandparent is not an RPC node, ignoring get-filter-element-attributes statement");
103 switch (greatGrandParent.getRawArgument()) {
108 LOG.debug("Great-grandparent is not named 'get' nor 'get-config, ignoring get-filter-element-attributes"