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.api.YangParserConfiguration;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
23 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
26 public final class OidStatementSupport
27 extends AbstractStatementSupport<ObjectIdentifier, OidStatement, OidEffectiveStatement> {
28 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
29 SubstatementValidator.builder(IetfYangSmiv2ExtensionsMapping.OBJECT_ID).build();
31 public OidStatementSupport(final YangParserConfiguration config) {
32 super(IetfYangSmiv2ExtensionsMapping.OBJECT_ID, StatementPolicy.contextIndependent(), config);
36 public ObjectIdentifier parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
38 return ObjectIdentifier.forString(value);
39 } catch (IllegalArgumentException e) {
40 throw new SourceException(ctx, e, "Invalid object identifier '%s'", value);
45 protected SubstatementValidator getSubstatementValidator() {
46 return SUBSTATEMENT_VALIDATOR;
50 protected OidStatement createDeclared(final StmtContext<ObjectIdentifier, OidStatement, ?> ctx,
51 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
52 return new OidIdStatementImpl(ctx.getArgument(), substatements);
56 protected OidEffectiveStatement createEffective(final Current<ObjectIdentifier, OidStatement> stmt,
57 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
58 return new OidEffectiveStatementImpl(stmt, substatements);