2 * Copyright (c) 2016, 2020 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.rfc6643.parser;
10 import com.google.common.annotations.Beta;
11 import com.google.common.collect.ImmutableList;
12 import org.opendaylight.yangtools.rfc6643.model.api.IetfYangSmiv2ExtensionsMapping;
13 import org.opendaylight.yangtools.rfc6643.model.api.ObjectIdentifier;
14 import org.opendaylight.yangtools.rfc6643.model.api.OidEffectiveStatement;
15 import org.opendaylight.yangtools.rfc6643.model.api.OidStatement;
16 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
17 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
18 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
23 public final class OidStatementSupport
24 extends BaseStatementSupport<ObjectIdentifier, OidStatement, OidEffectiveStatement> {
25 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
26 SubstatementValidator.builder(IetfYangSmiv2ExtensionsMapping.OBJECT_ID).build();
27 private static final OidStatementSupport INSTANCE = new OidStatementSupport();
29 private OidStatementSupport() {
30 super(IetfYangSmiv2ExtensionsMapping.OBJECT_ID);
33 public static OidStatementSupport getInstance() {
38 public ObjectIdentifier parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
39 return ObjectIdentifier.forString(value);
43 protected SubstatementValidator getSubstatementValidator() {
44 return SUBSTATEMENT_VALIDATOR;
48 protected OidStatement createDeclared(final StmtContext<ObjectIdentifier, OidStatement, ?> ctx,
49 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
50 return new OidIdStatementImpl(ctx.coerceStatementArgument(), substatements);
54 protected OidStatement createEmptyDeclared(final StmtContext<ObjectIdentifier, OidStatement, ?> ctx) {
55 return createDeclared(ctx, ImmutableList.of());
59 protected OidEffectiveStatement createEffective(
60 final StmtContext<ObjectIdentifier, OidStatement, OidEffectiveStatement> ctx,
61 final OidStatement declared, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
62 return new OidEffectiveStatementImpl(ctx, substatements);
66 protected OidEffectiveStatement createEmptyEffective(
67 final StmtContext<ObjectIdentifier, OidStatement, OidEffectiveStatement> ctx, final OidStatement declared) {
68 return createEffective(ctx, declared, ImmutableList.of());