Remove AbstractDOMRpcRoutingTableEntry.invokeRpc
[mdsal.git] / binding / mdsal-binding-generator-api / src / main / java / org / opendaylight / mdsal / binding / generator / 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.generator.api;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.collect.BiMap;
12 import com.google.common.collect.ImmutableBiMap;
13 import com.google.common.collect.ImmutableMap;
14 import com.google.common.collect.ImmutableMultimap;
15 import com.google.common.collect.Multimap;
16 import java.util.Collection;
17 import java.util.Map;
18 import java.util.Optional;
19 import javax.annotation.concurrent.ThreadSafe;
20 import org.opendaylight.mdsal.binding.model.api.Type;
21 import org.opendaylight.yangtools.concepts.Immutable;
22 import org.opendaylight.yangtools.yang.common.QName;
23 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
24 import org.opendaylight.yangtools.yang.model.api.DocumentedNode.WithStatus;
25
26 /**
27  * The result of BindingGenerator run. Contains mapping between Types and SchemaNodes.
28  */
29 @Beta
30 @ThreadSafe
31 public final class BindingRuntimeTypes implements Immutable {
32     private final Map<Type, AugmentationSchemaNode> typeToAugmentation;
33     private final BiMap<Type, WithStatus> typeToSchema;
34     private final Multimap<Type, Type> choiceToCases;
35     private final Map<QName, Type> identities;
36
37     public BindingRuntimeTypes(final Map<Type, AugmentationSchemaNode> typeToAugmentation,
38             final BiMap<Type, WithStatus> typeToDefiningSchema, final Multimap<Type, Type> choiceToCases,
39             final Map<QName, Type> identities) {
40         this.typeToAugmentation = ImmutableMap.copyOf(typeToAugmentation);
41         this.typeToSchema = ImmutableBiMap.copyOf(typeToDefiningSchema);
42         this.choiceToCases = ImmutableMultimap.copyOf(choiceToCases);
43         this.identities = ImmutableMap.copyOf(identities);
44     }
45
46     public Optional<AugmentationSchemaNode> findAugmentation(final Type type) {
47         return Optional.ofNullable(typeToAugmentation.get(type));
48     }
49
50     public Optional<Type> findIdentity(final QName qname) {
51         return Optional.ofNullable(identities.get(qname));
52     }
53
54     public Optional<WithStatus> findSchema(final Type type) {
55         return Optional.ofNullable(typeToSchema.get(type));
56     }
57
58     public Optional<Type> findType(final WithStatus schema) {
59         return Optional.ofNullable(typeToSchema.inverse().get(schema));
60     }
61
62     public Multimap<Type, Type> getChoiceToCases() {
63         return choiceToCases;
64     }
65
66     public Collection<Type> findCases(final Type choiceType) {
67         return choiceToCases.get(choiceType);
68     }
69 }