API Usability: Introduced type capture for Transaction Factory
[controller.git] / opendaylight / md-sal / sal-netconf-connector / src / main / java / org / opendaylight / controller / sal / connect / util / FailedRpcResult.java
1 /*
2  * Copyright (c) 2014 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.sal.connect.util;
9
10 import java.util.Collection;
11 import java.util.Collections;
12
13 import org.opendaylight.yangtools.yang.common.RpcError;
14 import org.opendaylight.yangtools.yang.common.RpcResult;
15
16 public final class FailedRpcResult<T> implements RpcResult<T> {
17
18     private final RpcError rpcError;
19
20     public FailedRpcResult(final RpcError rpcError) {
21         this.rpcError = rpcError;
22     }
23
24     @Override
25     public boolean isSuccessful() {
26         return false;
27     }
28
29     @Override
30     public T getResult() {
31         return null;
32     }
33
34     @Override
35     public Collection<RpcError> getErrors() {
36         return Collections.singletonList(rpcError);
37     }
38 }