BUG-5280: introduce Request/Response and related concepts
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / concepts / Response.java
diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Response.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Response.java
new file mode 100644 (file)
index 0000000..07acb27
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.access.concepts;
+
+import com.google.common.annotations.Beta;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.cluster.access.ABIVersion;
+import org.opendaylight.yangtools.concepts.WritableIdentifier;
+
+/**
+ * Abstract counterpart to a {@link Request}. This class should not be instantiated directly, but rather through
+ * {@link RequestFailure} and {@link RequestSuccess}, which provide appropriate specialization. It is visible purely for
+ * the purpose of allowing to check if an object is either of those specializations with a single instanceof check.
+ *
+ * @author Robert Varga
+ *
+ * @param <T> Target identifier type
+ * @param <C> Message type
+ */
+@Beta
+public abstract class Response<T extends WritableIdentifier, C extends Response<T, C>> extends Message<T, C> {
+    private static final long serialVersionUID = 1L;
+
+    Response(final @Nonnull C response, final @Nonnull ABIVersion version) {
+        super(response, version);
+    }
+
+    Response(final @Nonnull T target, final long sequence, final long retry) {
+        super(target, sequence, retry);
+    }
+
+    @Override
+    protected final C cloneAsRetry(final long retry) {
+        throw new UnsupportedOperationException("Responses do not support retries");
+    }
+
+    @Override
+    abstract AbstractResponseProxy<T, C> externalizableProxy(@Nonnull ABIVersion version);
+}