import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.require_instance.RequireInstanceStatementSupport;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.revision.RevisionStatementSupport;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.revision_date.RevisionDateStatementSupport;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.rpc.RpcStatementRFC6020Support;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.rpc.RpcStatementRFC7950Support;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.rpc.RpcStatementSupport;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.status.StatusStatementSupport;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.submodule.SubmoduleStatementRFC6020Support;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.submodule.SubmoduleStatementRFC7950Support;
.addSupport(ConfigListWarningNamespace.BEHAVIOUR)
.addSupport(UniqueStatementSupport.getInstance())
.addVersionSpecificSupport(VERSION_1_1, ActionStatementSupport.getInstance())
- .addVersionSpecificSupport(VERSION_1, RpcStatementRFC6020Support.getInstance())
- .addVersionSpecificSupport(VERSION_1_1, RpcStatementRFC7950Support.getInstance())
+ .addVersionSpecificSupport(VERSION_1, RpcStatementSupport.rfc6020Instance())
+ .addVersionSpecificSupport(VERSION_1_1, RpcStatementSupport.rfc7950Instance())
.addVersionSpecificSupport(VERSION_1, InputStatementSupport.rfc6020Instance())
.addVersionSpecificSupport(VERSION_1_1, InputStatementSupport.rfc7950Instance())
.addVersionSpecificSupport(VERSION_1, OutputStatementSupport.rfc6020Instance())
+++ /dev/null
-/*
- * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.rpc;
-
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.input.InputStatementSupport;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.output.OutputStatementSupport;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
-
-public final class RpcStatementRFC6020Support extends AbstractRpcStatementSupport {
- private static final RpcStatementRFC6020Support INSTANCE = new RpcStatementRFC6020Support();
-
- private RpcStatementRFC6020Support() {
- // Hidden
- }
-
- public static RpcStatementRFC6020Support getInstance() {
- return INSTANCE;
- }
-
- @Override
- StatementSupport<?, ?, ?> implictInput() {
- return InputStatementSupport.rfc6020Instance();
- }
-
- @Override
- StatementSupport<?, ?, ?> implictOutput() {
- return OutputStatementSupport.rfc6020Instance();
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.rpc;
-
-import com.google.common.annotations.Beta;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.input.InputStatementSupport;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.output.OutputStatementSupport;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
-
-/**
- * Bridge class for RFC7950 RPCs. Specializes implicit input/output statements.
- *
- * @author Robert Varga
- */
-@Beta
-public final class RpcStatementRFC7950Support extends AbstractRpcStatementSupport {
- private static final RpcStatementRFC7950Support INSTANCE = new RpcStatementRFC7950Support();
-
- private RpcStatementRFC7950Support() {
- // Hidden
- }
-
- public static RpcStatementRFC7950Support getInstance() {
- return INSTANCE;
- }
-
- @Override
- StatementSupport<?, ?, ?> implictInput() {
- return InputStatementSupport.rfc7950Instance();
- }
-
- @Override
- StatementSupport<?, ?, ?> implictOutput() {
- return OutputStatementSupport.rfc7950Instance();
- }
-}
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Verify.verify;
+import static java.util.Objects.requireNonNull;
+import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseSchemaTreeStatementSupport;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.EffectiveStatementWithFlags.FlagsBuilder;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.input.InputStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.output.OutputStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
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.StmtContextUtils;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
-abstract class AbstractRpcStatementSupport extends BaseSchemaTreeStatementSupport<RpcStatement, RpcEffectiveStatement> {
+@Beta
+public final class RpcStatementSupport extends BaseSchemaTreeStatementSupport<RpcStatement, RpcEffectiveStatement> {
private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
YangStmtMapping.RPC)
.addOptional(YangStmtMapping.DESCRIPTION)
.addOptional(YangStmtMapping.STATUS)
.addAny(YangStmtMapping.TYPEDEF)
.build();
+ private static final @NonNull RpcStatementSupport RFC6020_INSTANCE = new RpcStatementSupport(
+ InputStatementSupport.rfc6020Instance(), OutputStatementSupport.rfc6020Instance());
+ private static final @NonNull RpcStatementSupport RFC7950_INSTANCE = new RpcStatementSupport(
+ InputStatementSupport.rfc7950Instance(), OutputStatementSupport.rfc7950Instance());
- AbstractRpcStatementSupport() {
+ private final InputStatementSupport implicitInput;
+ private final OutputStatementSupport implicitOutput;
+
+ private RpcStatementSupport(final InputStatementSupport implicitInput,
+ final OutputStatementSupport implicitOutput) {
super(YangStmtMapping.RPC, CopyPolicy.DECLARED_COPY);
+ this.implicitInput = requireNonNull(implicitInput);
+ this.implicitOutput = requireNonNull(implicitOutput);
+ }
+
+ public static @NonNull RpcStatementSupport rfc6020Instance() {
+ return RFC6020_INSTANCE;
+ }
+
+ public static @NonNull RpcStatementSupport rfc7950Instance() {
+ return RFC7950_INSTANCE;
}
@Override
- public final void onFullDefinitionDeclared(final Mutable<QName, RpcStatement, RpcEffectiveStatement> stmt) {
+ public void onFullDefinitionDeclared(final Mutable<QName, RpcStatement, RpcEffectiveStatement> stmt) {
super.onFullDefinitionDeclared(stmt);
verify(stmt instanceof StatementContextBase);
if (StmtContextUtils.findFirstDeclaredSubstatement(stmt, InputStatement.class) == null) {
- ((StatementContextBase<?, ?, ?>) stmt).appendImplicitSubstatement(implictInput(), null);
+ ((StatementContextBase<?, ?, ?>) stmt).appendImplicitSubstatement(implicitInput, null);
}
if (StmtContextUtils.findFirstDeclaredSubstatement(stmt, OutputStatement.class) == null) {
- ((StatementContextBase<?, ?, ?>) stmt).appendImplicitSubstatement(implictOutput(), null);
+ ((StatementContextBase<?, ?, ?>) stmt).appendImplicitSubstatement(implicitOutput, null);
}
}
@Override
- protected final SubstatementValidator getSubstatementValidator() {
+ protected SubstatementValidator getSubstatementValidator() {
return SUBSTATEMENT_VALIDATOR;
}
@Override
- protected final RpcStatement createDeclared(final StmtContext<QName, RpcStatement, ?> ctx,
+ protected RpcStatement createDeclared(final StmtContext<QName, RpcStatement, ?> ctx,
final ImmutableList<? extends DeclaredStatement<?>> substatements) {
return new RegularRpcStatement(ctx.getArgument(), substatements);
}
@Override
- protected final RpcStatement createEmptyDeclared(final StmtContext<QName, RpcStatement, ?> ctx) {
+ protected RpcStatement createEmptyDeclared(final StmtContext<QName, RpcStatement, ?> ctx) {
return new EmptyRpcStatement(ctx.getArgument());
}
}
}
- abstract StatementSupport<?, ?, ?> implictInput();
-
- abstract StatementSupport<?, ?, ?> implictOutput();
-
private static int computeFlags(final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
return new FlagsBuilder()
.setStatus(findFirstArgument(substatements, StatusEffectiveStatement.class, Status.CURRENT))