2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.generator.impl.reactor;
10 import static com.google.common.base.Verify.verify;
11 import static com.google.common.base.Verify.verifyNotNull;
12 import static java.util.Objects.requireNonNull;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.yangtools.yang.model.api.stmt.AugmentEffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.UsesEffectiveStatement;
19 * Generator corresponding to a {@code augment} statement used as a child of a {@code uses} statement.
21 final class UsesAugmentGenerator extends AbstractAugmentGenerator {
22 private final UsesEffectiveStatement uses;
24 private GroupingGenerator grouping;
26 UsesAugmentGenerator(final AugmentEffectiveStatement statement, final UsesEffectiveStatement uses,
27 final AbstractCompositeGenerator<?> parent) {
28 super(statement, parent);
29 this.uses = requireNonNull(uses);
32 void resolveGrouping(final UsesEffectiveStatement resolvedUses, final GroupingGenerator resolvedGrouping) {
33 if (resolvedUses == uses) {
34 verify(grouping == null, "Attempted to re-resolve grouping of %s", this);
35 grouping = requireNonNull(resolvedGrouping);
39 @NonNull AugmentRequirement startLinkage() {
40 // Here we are going in the opposite direction of RFC7950, section 7.13:
42 // The effect of a "uses" reference to a grouping is that the nodes
43 // defined by the grouping are copied into the current schema tree and
44 // are then updated according to the "refine" and "augment" statements.
46 // Our parent here is *not* the 'uses' statement, but rather the statement which contains it.
47 return new AugmentRequirement(this, verifyNotNull(grouping, "Unresolved grouping in %s", this));