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