Cleaned up sal-dom-* packages and removed legacy interfaces
[mdsal.git] / dom / mdsal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / broker / impl / PingPongFuture.java
diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongFuture.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongFuture.java
new file mode 100644 (file)
index 0000000..68ef760
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.sal.dom.broker.impl;
+
+import com.google.common.util.concurrent.AbstractCheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+
+/**
+ * A {@link java.util.concurrent.Future} used to report the status of an future
+ * {@link java.util.concurrent.Future}.
+ */
+final class PingPongFuture extends AbstractCheckedFuture<Void, TransactionCommitFailedException> {
+  protected PingPongFuture(final ListenableFuture<Void> delegate) {
+    super(delegate);
+  }
+
+  @Override
+  protected TransactionCommitFailedException mapException(final Exception e) {
+    if (e.getCause() instanceof TransactionCommitFailedException){
+      return (TransactionCommitFailedException) e.getCause();
+    } else {
+            return new TransactionCommitFailedException(e.getMessage(), e.getCause());
+    }
+  }
+}
+