Merge "Fix bug 153: change the key container-config to ContainerConfig in the contain...
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / codegen / impl / RpcRoutingTableImpl.xtend
1 package org.opendaylight.controller.sal.binding.codegen.impl
2
3 import org.opendaylight.controller.sal.binding.spi.RpcRoutingTable
4 import org.opendaylight.yangtools.yang.binding.BaseIdentity
5 import org.opendaylight.yangtools.yang.binding.RpcService
6 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
7 import java.util.Map
8 import org.opendaylight.yangtools.yang.binding.DataObject
9 import java.util.HashMap
10
11 class RpcRoutingTableImpl<C extends BaseIdentity,S extends RpcService> implements RpcRoutingTable<C,S>{
12     
13     @Property
14     val Class<C> identifier;
15     
16     @Property
17     var S defaultRoute;
18     
19     @Property
20     val Map<InstanceIdentifier<? extends DataObject>,S> routes;
21     
22     new(Class<C> ident, Map<InstanceIdentifier<? extends DataObject>,S> route) {
23         _identifier = ident
24         _routes = route
25     }
26     
27     new(Class<C> ident) {
28         _identifier = ident
29         _routes = new HashMap
30     }
31     
32     
33     override getRoute(InstanceIdentifier<? extends Object> nodeInstance) {
34         val ret = routes.get(nodeInstance);
35         if(ret !== null) {
36             return ret;
37         }
38         return defaultRoute;
39     }
40     
41     override removeRoute(InstanceIdentifier<? extends Object> path) {
42         routes.remove(path);
43     }
44     
45     @SuppressWarnings("rawtypes")
46     override updateRoute(InstanceIdentifier<? extends Object> path, S service) {
47         routes.put(path as InstanceIdentifier<? extends DataObject>,service);
48     }
49 }