Migrate netconf-client-mdsal/api tests to JUnit5
[netconf.git] / restconf / restconf-common / src / main / java / org / opendaylight / restconf / common / errors / RestconfCallback.java
1 /*
2  * Copyright (c) 2023 PANTHEON.tech, s.r.o. 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.restconf.common.errors;
9
10 import com.google.common.util.concurrent.FutureCallback;
11 import org.eclipse.jdt.annotation.NonNull;
12
13 /**
14  * A {@link FutureCallback} tied to a {@link RestconfFuture}.
15  *
16  * @param <V> value type
17  */
18 public abstract class RestconfCallback<V> implements FutureCallback<@NonNull V> {
19     @Override
20     public final void onFailure(final Throwable cause) {
21         onFailure(cause instanceof RestconfDocumentedException rde ? rde
22             : new RestconfDocumentedException("Unexpected failure", cause));
23     }
24
25     protected abstract void onFailure(@NonNull RestconfDocumentedException failure);
26 }