ed3d5c3e00386d9778b1478d8638acdfcb7eec6c
[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 final class RpcGenerator extends AbstractInvokableGenerator<RpcEffectiveStatement, RpcRuntimeType> {
24     RpcGenerator(final RpcEffectiveStatement statement, final ModuleGenerator parent) {
25         super(statement, parent);
26     }
27
28     @Override
29     StatementNamespace namespace() {
30         return StatementNamespace.RPC;
31     }
32
33     @Override
34     ClassPlacement classPlacement() {
35         return ClassPlacement.TOP_LEVEL;
36     }
37
38     @Override
39     ParameterizedType implementedType(final TypeBuilderFactory builderFactory, final GeneratedType input,
40             final GeneratedType output) {
41         return BindingTypes.rpc(input, output);
42     }
43
44     @Override
45     CompositeRuntimeTypeBuilder<RpcEffectiveStatement, RpcRuntimeType> createBuilder(
46             final RpcEffectiveStatement statement) {
47         return new InvokableRuntimeTypeBuilder<>(statement) {
48             @Override
49             RpcRuntimeType build(final GeneratedType generatedType, final RpcEffectiveStatement statement,
50                     final List<RuntimeType> childTypes) {
51                 return new DefaultRpcRuntimeType(generatedType, statement, childTypes);
52             }
53         };
54     }
55 }