Rework BindingRuntimeTypes
[mdsal.git] / binding / mdsal-binding-runtime-api / src / main / java / org / opendaylight / mdsal / binding / runtime / api / BindingRuntimeTypes.java
index d0ac16642ab2fbe5979223eccbdfe1f15bd1d7fb..73235013f51ca3d187b1708bdf65ae66dc2cd944 100644 (file)
@@ -8,33 +8,34 @@
 package org.opendaylight.mdsal.binding.runtime.api;
 
 import com.google.common.annotations.Beta;
-import com.google.common.collect.Multimap;
-import java.util.Collection;
 import java.util.Optional;
-import org.opendaylight.mdsal.binding.model.api.Type;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DocumentedNode.WithStatus;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
 
 /**
  * The result of BindingGenerator run. Contains mapping between Types and SchemaNodes.
  */
 @Beta
-public interface BindingRuntimeTypes extends EffectiveModelContextProvider, Immutable {
+public interface BindingRuntimeTypes extends EffectiveModelContextProvider, RuntimeTypeContainer, Immutable {
 
-    Optional<AugmentationSchemaNode> findAugmentation(Type type);
+    Optional<IdentityRuntimeType> findIdentity(QName qname);
 
-    Optional<Type> findIdentity(QName qname);
+    Optional<RuntimeType> findSchema(JavaTypeName typeName);
 
-    Optional<WithStatus> findSchema(Type type);
+    Optional<InputRuntimeType> findRpcInput(QName rpcName);
 
-    Optional<Type> findType(WithStatus schema);
+    Optional<OutputRuntimeType> findRpcOutput(QName rpcName);
 
-    Optional<Type> findOriginalAugmentationType(AugmentationSchemaNode augment);
-
-    Multimap<Type, Type> getChoiceToCases();
-
-    Collection<Type> findCases(Type choiceType);
+    default @Nullable RuntimeType schemaTreeChild(final Absolute path) {
+        final var it = path.getNodeIdentifiers().iterator();
+        var tmp = schemaTreeChild(it.next());
+        while (it.hasNext() && tmp instanceof RuntimeTypeContainer) {
+            tmp = ((RuntimeTypeContainer) tmp).schemaTreeChild(it.next());
+        }
+        return tmp;
+    }
 }