Migrate OSGI compendium reference
[controller.git] / opendaylight / md-sal / sal-dom-compat / src / main / java / org / opendaylight / controller / sal / core / compat / ReadFailedExceptionAdapter.java
1 /*
2  * Copyright (c) 2018 Inocybe Technologies 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.core.compat;
9
10 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
11 import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
12
13 /**
14  * Adapter that maps the controller API-based ReadFailedException to the mdsal API-based ReadFailedException.
15  *
16  * @author Thomas Pantelis
17  */
18 @Deprecated(forRemoval = true)
19 public final class ReadFailedExceptionAdapter extends ExceptionMapper<ReadFailedException> {
20     public static final ReadFailedExceptionAdapter INSTANCE = new ReadFailedExceptionAdapter();
21
22     private ReadFailedExceptionAdapter() {
23         super("read", ReadFailedException.class);
24     }
25
26     @Override
27     protected ReadFailedException newWithCause(String message, Throwable cause) {
28         if (cause instanceof org.opendaylight.mdsal.common.api.ReadFailedException) {
29             return new ReadFailedException(cause.getMessage(), cause.getCause());
30         }
31
32         return new ReadFailedException(message, cause);
33     }
34 }