Refactor augment generator linkage
[yangtools.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / generator / impl / reactor / UsesAugmentGenerator.java
1 /*
2  * Copyright (c) 2020 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.yangtools.yang.model.api.stmt.AugmentEffectiveStatement;
11
12 /**
13  * Generator corresponding to a {@code augment} statement used as a child of a {@code uses} statement.
14  */
15 final class UsesAugmentGenerator extends AbstractAugmentGenerator {
16     UsesAugmentGenerator(final AugmentEffectiveStatement statement, final AbstractCompositeGenerator<?> parent) {
17         super(statement, parent);
18     }
19
20     @Override
21     void loadTargetGenerator() {
22         // Here we are going in the opposite direction of RFC7950, section 7.13:
23         //
24         //    The effect of a "uses" reference to a grouping is that the nodes
25         //    defined by the grouping are copied into the current schema tree and
26         //    are then updated according to the "refine" and "augment" statements.
27         //
28         // Our parent here is *not* the uses statement, but rather the statement which contains uses -- and its
29         // getSchemaTreeGenerator() is well equipped to deal with the namespace hopping needed to perform the lookups
30         setTargetGenerator(getParent().resolveSchemaNode(statement().argument()));
31     }
32 }