Track schema tree generator linkage
[mdsal.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / generator / impl / tree / SchemaTreeChild.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.tree;
9
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.mdsal.binding.generator.impl.reactor.AbstractExplicitGenerator;
12 import org.opendaylight.yangtools.concepts.Identifiable;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
15
16 /**
17  * An object reflecting a YANG {@code schema node}.
18  *
19  * @param <S> Concrete {@link SchemaTreeEffectiveStatement} type
20  * @param <G> Concrete {@link AbstractExplicitGenerator} type
21  */
22 // FIXME: do not reference Generator once we have the codegen and runtime views well-defined
23 public interface SchemaTreeChild<S extends SchemaTreeEffectiveStatement<?>,
24         G extends AbstractExplicitGenerator<S> & SchemaTreeChild<S, G>> extends Identifiable<QName> {
25     @Override
26     default QName getIdentifier() {
27         return statement().argument();
28     }
29
30     /**
31      * Return the effective YANG statement being represented by this object.
32      *
33      * @return A YANG statement
34      */
35     @NonNull S statement();
36
37     /**
38      * Return the generator responsible for handling the binding type view of this statement. Note that the statement
39      * returned by {@code generator().statement()} may differ from the statement returned by {@link #statement()}.
40      *
41      * @return Underlying binding generator
42      * @throws IllegalStateException if the generator has not been resolved yet
43      */
44     @NonNull G generator();
45 }