Fix findbugs violations in md-sal - part 2
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / broker / impl / TransactionCommitFailedExceptionMapper.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.md.sal.dom.broker.impl;
9
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;
13
14 /**
15  * Utility exception mapper which translates Exception to {@link TransactionCommitFailedException}.
16  *
17  * @see ExceptionMapper
18  */
19 public final class TransactionCommitFailedExceptionMapper extends ExceptionMapper<TransactionCommitFailedException> {
20
21     public static final TransactionCommitFailedExceptionMapper PRE_COMMIT_MAPPER = create("preCommit");
22
23     public static final TransactionCommitFailedExceptionMapper CAN_COMMIT_ERROR_MAPPER = create("canCommit");
24
25     public static final TransactionCommitFailedExceptionMapper COMMIT_ERROR_MAPPER = create("commit");
26
27     private TransactionCommitFailedExceptionMapper(final String opName) {
28         super(opName, TransactionCommitFailedException.class);
29     }
30
31     public static TransactionCommitFailedExceptionMapper create(final String opName) {
32         return new TransactionCommitFailedExceptionMapper(opName);
33     }
34
35     @Override
36     protected TransactionCommitFailedException newWithCause(final String message, final Throwable cause) {
37         return new TransactionCommitFailedException(message, cause);
38     }
39
40     @Override
41     @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
42     public TransactionCommitFailedException apply(Exception input) {
43         return super.apply(input);
44     }
45 }