2 * Copyright (c) 2016 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.cluster.access.concepts;
10 import java.io.IOException;
11 import java.io.ObjectInput;
12 import java.io.ObjectOutput;
13 import java.io.Serial;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.yangtools.concepts.WritableIdentifier;
18 * Abstract Externalizable proxy for use with {@link RequestFailure} subclasses.
20 * @param <T> Target identifier type
22 public abstract class AbstractRequestFailureProxy<T extends WritableIdentifier, C extends RequestFailure<T, C>>
23 extends AbstractResponseProxy<T, C> {
25 private static final long serialVersionUID = 1L;
27 private RequestException cause;
29 protected AbstractRequestFailureProxy() {
33 protected AbstractRequestFailureProxy(final @NonNull C failure) {
35 this.cause = failure.getCause();
39 public void writeExternal(final ObjectOutput out) throws IOException {
40 super.writeExternal(out);
41 out.writeObject(cause);
45 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
46 super.readExternal(in);
47 cause = (RequestException) in.readObject();
51 final C createResponse(final T target, final long sequence) {
52 return createFailure(target, sequence, cause);
55 protected abstract @NonNull C createFailure(@NonNull T target, long sequence,
56 @NonNull RequestException failureCause);