37745e3036da4c737ab518bc841490e8b66f5b9d
[mdsal.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / generator / impl / reactor / InputGenerator.java
1 /*
2  * Copyright (c) 2022 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.reactor.CollisionDomain.Member;
12 import org.opendaylight.mdsal.binding.generator.impl.rt.DefaultInputRuntimeType;
13 import org.opendaylight.mdsal.binding.model.api.GeneratedType;
14 import org.opendaylight.mdsal.binding.model.ri.BindingTypes;
15 import org.opendaylight.mdsal.binding.runtime.api.AugmentRuntimeType;
16 import org.opendaylight.mdsal.binding.runtime.api.InputRuntimeType;
17 import org.opendaylight.mdsal.binding.runtime.api.RuntimeType;
18 import org.opendaylight.yangtools.yang.binding.contract.StatementNamespace;
19 import org.opendaylight.yangtools.yang.model.api.stmt.InputEffectiveStatement;
20
21 /**
22  * Generator corresponding to an {@code input} statement. We use a combination of the operation name and "Input"
23  * as the name. This makes it easier to support multiple RPCs/actions in one source file, as we can import them without
24  * a conflict.
25  */
26 // FIXME: hide this once we have RpcRuntimeType
27 public final class InputGenerator extends OperationContainerGenerator<InputEffectiveStatement, InputRuntimeType> {
28     InputGenerator(final InputEffectiveStatement statement, final AbstractCompositeGenerator<?, ?> parent) {
29         super(statement, parent, BindingTypes.RPC_INPUT);
30     }
31
32     @Override
33     StatementNamespace namespace() {
34         return StatementNamespace.INPUT;
35     }
36
37     @Override
38     Member createMember(final CollisionDomain domain, final Member parent) {
39         return domain.addSecondary(this, parent);
40     }
41
42     @Override
43     CompositeRuntimeTypeBuilder<InputEffectiveStatement, InputRuntimeType> createBuilder(
44             final InputEffectiveStatement statement) {
45         return new CompositeRuntimeTypeBuilder<>(statement) {
46             @Override
47             InputRuntimeType build(final GeneratedType type, final InputEffectiveStatement statement,
48                     final List<RuntimeType> children, final List<AugmentRuntimeType> augments) {
49                 return new DefaultInputRuntimeType(type, statement, children, augments);
50             }
51         };
52     }
53 }