Deprecated Rpcs and RpcErrors helper classes
[controller.git] / opendaylight / md-sal / sal-common-util / src / main / java / org / opendaylight / controller / sal / common / util / CommitHandlerTransactions.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.common.util;
9
10 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
11 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
12 import org.opendaylight.yangtools.concepts.Path;
13 import org.opendaylight.yangtools.yang.common.RpcResult;
14 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
15
16 public class CommitHandlerTransactions {
17
18     private static class AllwaysSuccessfulTransaction<P extends Path<P>,D> implements DataCommitTransaction<P, D> {
19
20         private final  DataModification<P, D> modification;
21
22         public AllwaysSuccessfulTransaction(DataModification<P, D> modification) {
23             this.modification = modification;
24         }
25         @Override
26         public RpcResult<Void> rollback() throws IllegalStateException {
27             return RpcResultBuilder.<Void>success().build();
28         }
29         @Override
30         public RpcResult<Void> finish() throws IllegalStateException {
31             return RpcResultBuilder.<Void>success().build();
32         }
33
34         @Override
35         public DataModification<P, D> getModification() {
36             return modification;
37         }
38     }
39
40     public static final <P extends Path<P>,D> AllwaysSuccessfulTransaction<P, D> allwaysSuccessfulTransaction(DataModification<P, D> modification)  {
41         return new AllwaysSuccessfulTransaction<>(modification);
42     }
43 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.