73235013f51ca3d187b1708bdf65ae66dc2cd944
[mdsal.git] / binding / mdsal-binding-runtime-api / src / main / java / org / opendaylight / mdsal / binding / runtime / api / BindingRuntimeTypes.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o.  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.runtime.api;
9
10 import com.google.common.annotations.Beta;
11 import java.util.Optional;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
14 import org.opendaylight.yangtools.concepts.Immutable;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
17 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
18
19 /**
20  * The result of BindingGenerator run. Contains mapping between Types and SchemaNodes.
21  */
22 @Beta
23 public interface BindingRuntimeTypes extends EffectiveModelContextProvider, RuntimeTypeContainer, Immutable {
24
25     Optional<IdentityRuntimeType> findIdentity(QName qname);
26
27     Optional<RuntimeType> findSchema(JavaTypeName typeName);
28
29     Optional<InputRuntimeType> findRpcInput(QName rpcName);
30
31     Optional<OutputRuntimeType> findRpcOutput(QName rpcName);
32
33     default @Nullable RuntimeType schemaTreeChild(final Absolute path) {
34         final var it = path.getNodeIdentifiers().iterator();
35         var tmp = schemaTreeChild(it.next());
36         while (it.hasNext() && tmp instanceof RuntimeTypeContainer) {
37             tmp = ((RuntimeTypeContainer) tmp).schemaTreeChild(it.next());
38         }
39         return tmp;
40     }
41 }