2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.md.sal.dom.broker.impl;
10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
11 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
12 import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
15 * Utility exception mapper which translates Exception to {@link TransactionCommitFailedException}.
17 * @see ExceptionMapper
20 public final class TransactionCommitFailedExceptionMapper extends ExceptionMapper<TransactionCommitFailedException> {
22 public static final TransactionCommitFailedExceptionMapper PRE_COMMIT_MAPPER = create("preCommit");
24 public static final TransactionCommitFailedExceptionMapper CAN_COMMIT_ERROR_MAPPER = create("canCommit");
26 public static final TransactionCommitFailedExceptionMapper COMMIT_ERROR_MAPPER = create("commit");
28 private TransactionCommitFailedExceptionMapper(final String opName) {
29 super(opName, TransactionCommitFailedException.class);
32 public static TransactionCommitFailedExceptionMapper create(final String opName) {
33 return new TransactionCommitFailedExceptionMapper(opName);
37 protected TransactionCommitFailedException newWithCause(final String message, final Throwable cause) {
38 return new TransactionCommitFailedException(message, cause);
42 @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
43 public TransactionCommitFailedException apply(Exception input) {
44 return super.apply(input);