1af7ccc79ad2de55b1f26a3b53b11b6b44bfadea
[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 java.util.Collections;
11
12 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
13 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
14 import org.opendaylight.yangtools.concepts.Path;
15 import org.opendaylight.yangtools.yang.common.RpcError;
16 import org.opendaylight.yangtools.yang.common.RpcResult;
17
18 public class CommitHandlerTransactions {
19
20     private static class AllwaysSuccessfulTransaction<P extends Path<P>,D> implements DataCommitTransaction<P, D> {
21
22         private final  DataModification<P, D> modification;
23
24         public AllwaysSuccessfulTransaction(DataModification<P, D> modification) {
25             this.modification = modification;
26         }
27         @Override
28         public RpcResult<Void> rollback() throws IllegalStateException {
29             return Rpcs.<Void>getRpcResult(true, null, Collections.<RpcError>emptyList());
30         }
31         @Override
32         public RpcResult<Void> finish() throws IllegalStateException {
33             return Rpcs.<Void>getRpcResult(true, null, Collections.<RpcError>emptyList());
34         }
35
36         @Override
37         public DataModification<P, D> getModification() {
38             return modification;
39         }
40     }
41
42     public static final <P extends Path<P>,D> AllwaysSuccessfulTransaction<P, D> allwaysSuccessfulTransaction(DataModification<P, D> modification)  {
43         return new AllwaysSuccessfulTransaction<>(modification);
44     }
45 }

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