2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.runtime.api;
10 import com.google.common.annotations.Beta;
11 import java.util.Optional;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.eclipse.jdt.annotation.Nullable;
15 import org.opendaylight.mdsal.binding.model.api.GeneratedType;
16 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
17 import org.opendaylight.yangtools.concepts.Immutable;
18 import org.opendaylight.yangtools.yang.common.QName;
19 import org.opendaylight.yangtools.yang.common.YangDataName;
20 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
21 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
24 * The result of BindingGenerator run. Contains mapping between Types and SchemaNodes.
27 public interface BindingRuntimeTypes extends EffectiveModelContextProvider, RuntimeTypeContainer, Immutable {
29 Optional<IdentityRuntimeType> findIdentity(QName qname);
31 Optional<RuntimeType> findSchema(JavaTypeName typeName);
33 Optional<InputRuntimeType> findRpcInput(QName rpcName);
35 Optional<OutputRuntimeType> findRpcOutput(QName rpcName);
37 Optional<YangDataRuntimeType> findYangData(YangDataName templateName);
39 default @Nullable RuntimeType schemaTreeChild(final Absolute path) {
40 final var it = path.getNodeIdentifiers().iterator();
41 var tmp = schemaTreeChild(it.next());
42 while (it.hasNext() && tmp instanceof RuntimeTypeContainer container) {
43 tmp = container.schemaTreeChild(it.next());
49 * Lookup to all {@link CaseRuntimeType}s related to a {@link ChoiceRuntimeType}. This is important when dealing
50 * with sharing incurred by Binding Spec's reuse of constructs defined in a {@code grouping}.
53 * As an example, consider {@link ChoiceRuntimeType} and {@link CaseRuntimeType} relationship to
54 * {@link GeneratedType}s in the following model:
71 * augment /foo/foo/bar {
75 * augment /bar/foo/bar {
80 * YANG view of what is valid in {@code /foo/foo/bar} differs from what is valid in {@code /bar/foo/bar}, but this
81 * difference is not reflected in generated Java constructs. More notably, the two augments being in different
82 * modules. Since {@code choice bar}'s is part of a reusable construct, {@code grouping one}, DataObjects' copy
83 * builders can propagate them without translating them to the appropriate manifestation -- and they can do nothing
84 * about that as they lack the complete view of the effective model.
87 * This method provides a bridge between a particular instantiation of a {@code choice} to {@link CaseRuntimeType}s
88 * valid in all instantiations.
90 * @param choiceType A ChoiceRuntimeType
91 * @return The set of {@link CaseRuntimeType}s known to this instance
92 * @throws NullPointerException if {@code ChoiceRuntimeType} is null
94 @NonNull Set<CaseRuntimeType> allCaseChildren(ChoiceRuntimeType choiceType);