Removed uncessary calls to RpcBroker to find routes.
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / main / java / org / opendaylight / controller / remote / rpc / RemoteRpcInput.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  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.controller.remote.rpc;
9 import com.google.common.base.Optional;
10 import com.google.common.base.Preconditions;
11 import java.util.Collection;
12 import java.util.Map;
13 import org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeSerializer;
14 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
18 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
19 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
20 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
21
22
23 class RemoteRpcInput implements ContainerNode {
24
25     private final ContainerNode delegate;
26
27     private RemoteRpcInput(final ContainerNode delegate) {
28         this.delegate = delegate;
29     }
30
31     protected static RemoteRpcInput from(final Node node) {
32         if(node == null) {
33             return null;
34         }
35         final NormalizedNode<?, ?> deserialized = NormalizedNodeSerializer.deSerialize(node);
36         Preconditions.checkArgument(deserialized instanceof ContainerNode);
37         return new RemoteRpcInput((ContainerNode) deserialized);
38     }
39
40     ContainerNode delegate() {
41         return delegate;
42     }
43
44     @Override
45     public Map<QName, String> getAttributes() {
46         return delegate().getAttributes();
47     }
48
49     @Override
50     public Object getAttributeValue(final QName name) {
51         return delegate().getAttributeValue(name);
52     }
53
54     @Override
55     public QName getNodeType() {
56         return delegate().getNodeType();
57     }
58
59     @Override
60     public Collection<DataContainerChild<? extends PathArgument, ?>> getValue() {
61         return delegate().getValue();
62     }
63
64     @Override
65     public NodeIdentifier getIdentifier() {
66         return delegate().getIdentifier();
67     }
68
69     @Override
70     public Optional<DataContainerChild<? extends PathArgument, ?>> getChild(final PathArgument child) {
71         return delegate().getChild(child);
72     }
73
74     @Override
75     public int hashCode() {
76         return delegate().hashCode();
77     }
78
79     @Override
80     public boolean equals(final Object obj) {
81         return delegate().equals(obj);
82     }
83 }