2 * Copyright (c) 2017 Pantheon Technologies, 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.yang.parser.rfc7950.stmt.refine;
10 import com.google.common.collect.ImmutableList;
11 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
12 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
13 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
14 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.RefineEffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.RefineStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Descendant;
18 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ArgumentUtils;
19 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
23 abstract class AbstractRefineStatementSupport
24 extends BaseStatementSupport<Descendant, RefineStatement, RefineEffectiveStatement> {
26 AbstractRefineStatementSupport() {
27 super(YangStmtMapping.REFINE);
31 public final Descendant parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
32 return ArgumentUtils.parseDescendantSchemaNodeIdentifier(ctx, value);
36 protected final RefineStatement createDeclared(final StmtContext<Descendant, RefineStatement, ?> ctx,
37 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
38 return new RefineStatementImpl(ctx.getRawArgument(), ctx.getArgument(), substatements);
42 protected final RefineStatement createEmptyDeclared(final StmtContext<Descendant, RefineStatement, ?> ctx) {
43 // Empty refine is exceedingly unlikely: let's be lazy and reuse the implementation
44 return createDeclared(ctx, ImmutableList.of());
48 protected final RefineEffectiveStatement createEffective(final Current<Descendant, RefineStatement> stmt,
49 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
50 // Empty refine is exceedingly unlikely: let's be lazy and reuse the implementation
51 return new RefineEffectiveStatementImpl(stmt.declared(), substatements, stmt.getSchemaPath(),
52 (SchemaNode) stmt.caerbannog().getEffectOfStatement().iterator().next().buildEffective());