Track schema tree generator linkage
[mdsal.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / generator / impl / reactor / ChoiceGenerator.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 org.opendaylight.mdsal.binding.model.api.GeneratedType;
11 import org.opendaylight.mdsal.binding.model.api.Type;
12 import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder;
13 import org.opendaylight.mdsal.binding.model.ri.BindingTypes;
14 import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
16
17 /**
18  * Generator corresponding to a {@code choice} statement.
19  */
20 final class ChoiceGenerator extends CompositeSchemaTreeGenerator<ChoiceEffectiveStatement, ChoiceGenerator> {
21     ChoiceGenerator(final ChoiceEffectiveStatement statement, final AbstractCompositeGenerator<?> parent) {
22         super(statement, parent);
23     }
24
25     @Override
26     void pushToInference(final SchemaInferenceStack dataTree) {
27         // No-op
28     }
29
30     @Override
31     GeneratedType createTypeImpl(final TypeBuilderFactory builderFactory) {
32         final GeneratedTypeBuilder builder = builderFactory.newGeneratedTypeBuilder(typeName());
33         builder.addImplementsType(BindingTypes.choiceIn(Type.of(getParent().typeName())));
34
35         final ModuleGenerator module = currentModule();
36         module.addQNameConstant(builder, localName());
37
38         annotateDeprecatedIfNecessary(builder);
39         builderFactory.addCodegenInformation(module, statement(), builder);
40 //      newType.setSchemaPath(schemaNode.getPath());
41         builder.setModuleName(module.statement().argument().getLocalName());
42
43         return builder.build();
44     }
45 }