38c76bc28469ebac188890324daed061531366c3
[mdsal.git] / dom / mdsal-dom-broker / src / main / java / org / opendaylight / mdsal / dom / broker / UnknownDOMRpcRoutingTableEntry.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.mdsal.dom.broker;
9
10 import org.opendaylight.mdsal.dom.api.DOMRpcException;
11 import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
12 import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException;
13 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
14
15 import com.google.common.util.concurrent.CheckedFuture;
16 import com.google.common.util.concurrent.Futures;
17 import java.util.List;
18 import java.util.Map;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
21 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
22
23 final class UnknownDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEntry {
24     private final CheckedFuture<DOMRpcResult, DOMRpcException> unknownRpc;
25
26     UnknownDOMRpcRoutingTableEntry(final SchemaPath schemaPath, final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
27         super(schemaPath, impls);
28         unknownRpc = Futures.<DOMRpcResult, DOMRpcException>immediateFailedCheckedFuture(
29             new DOMRpcImplementationNotAvailableException("SchemaPath %s is not resolved to an RPC", schemaPath));
30     }
31
32     @Override
33     protected CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final NormalizedNode<?, ?> input) {
34         return unknownRpc;
35     }
36
37     @Override
38     protected UnknownDOMRpcRoutingTableEntry newInstance(final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
39         return new UnknownDOMRpcRoutingTableEntry(getSchemaPath(), impls);
40     }
41 }