Move StatementNamespace to yang.binding.contract
[mdsal.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / generator / impl / reactor / RpcGenerator.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.mdsal.binding.generator.impl.reactor;
9
10 import java.util.List;
11 import org.opendaylight.mdsal.binding.generator.impl.rt.DefaultRpcRuntimeType;
12 import org.opendaylight.mdsal.binding.model.api.GeneratedType;
13 import org.opendaylight.mdsal.binding.model.api.ParameterizedType;
14 import org.opendaylight.mdsal.binding.model.ri.BindingTypes;
15 import org.opendaylight.mdsal.binding.runtime.api.RpcRuntimeType;
16 import org.opendaylight.mdsal.binding.runtime.api.RuntimeType;
17 import org.opendaylight.yangtools.yang.binding.contract.StatementNamespace;
18 import org.opendaylight.yangtools.yang.model.api.stmt.RpcEffectiveStatement;
19
20 /**
21  * Generator corresponding to a {@code rpc} statement.
22  */
23 // FIXME: hide this once we have RpcRuntimeType
24 public final class RpcGenerator extends AbstractInvokableGenerator<RpcEffectiveStatement, RpcRuntimeType> {
25     RpcGenerator(final RpcEffectiveStatement statement, final ModuleGenerator parent) {
26         super(statement, parent);
27     }
28
29     @Override
30     StatementNamespace namespace() {
31         return StatementNamespace.RPC;
32     }
33
34     @Override
35     ClassPlacement classPlacement() {
36         return ClassPlacement.TOP_LEVEL;
37     }
38
39     @Override
40     ParameterizedType implementedType(final TypeBuilderFactory builderFactory, final GeneratedType input,
41             final GeneratedType output) {
42         return BindingTypes.rpc(input, output);
43     }
44
45     @Override
46     CompositeRuntimeTypeBuilder<RpcEffectiveStatement, RpcRuntimeType> createBuilder(
47             final RpcEffectiveStatement statement) {
48         return new InvokableRuntimeTypeBuilder<>(statement) {
49             @Override
50             RpcRuntimeType build(final GeneratedType generatedType, final RpcEffectiveStatement statement,
51                     final List<RuntimeType> childTypes) {
52                 return new DefaultRpcRuntimeType(generatedType, statement, childTypes);
53             }
54         };
55     }
56 }