Merge "Fix for Bug 3"
[controller.git] / opendaylight / md-sal / sal-common-util / src / main / java / org / opendaylight / controller / sal / common / util / CommitHandlerTransactions.java
1 package org.opendaylight.controller.sal.common.util;
2
3 import java.util.Collections;
4
5 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
6 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
7 import org.opendaylight.yangtools.concepts.Path;
8 import org.opendaylight.yangtools.yang.common.RpcError;
9 import org.opendaylight.yangtools.yang.common.RpcResult;
10
11 public class CommitHandlerTransactions {
12
13     private static class AllwaysSuccessfulTransaction<P extends Path<P>,D> implements DataCommitTransaction<P, D> {
14         
15         private final  DataModification<P, D> modification;
16
17         public AllwaysSuccessfulTransaction(DataModification<P, D> modification) {
18             this.modification = modification;
19         }
20         @Override
21         public RpcResult<Void> rollback() throws IllegalStateException {
22             return Rpcs.<Void>getRpcResult(true, null, Collections.<RpcError>emptyList());
23         }
24         @Override
25         public RpcResult<Void> finish() throws IllegalStateException {
26             return Rpcs.<Void>getRpcResult(true, null, Collections.<RpcError>emptyList());
27         }
28         
29         @Override
30         public DataModification<P, D> getModification() {
31             return modification;
32         }
33     }
34     
35     public static final <P extends Path<P>,D> AllwaysSuccessfulTransaction<P, D> allwaysSuccessfulTransaction(DataModification<P, D> modification)  {
36         return new AllwaysSuccessfulTransaction<>(modification);
37     }
38 }

©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.