aboutsummaryrefslogtreecommitdiffstats
path: root/documentapi/src/main/java/com/yahoo/documentapi/DocumentUpdateResponse.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /documentapi/src/main/java/com/yahoo/documentapi/DocumentUpdateResponse.java
Publish
Diffstat (limited to 'documentapi/src/main/java/com/yahoo/documentapi/DocumentUpdateResponse.java')
-rw-r--r--documentapi/src/main/java/com/yahoo/documentapi/DocumentUpdateResponse.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/documentapi/src/main/java/com/yahoo/documentapi/DocumentUpdateResponse.java b/documentapi/src/main/java/com/yahoo/documentapi/DocumentUpdateResponse.java
new file mode 100644
index 00000000000..44044a41bc3
--- /dev/null
+++ b/documentapi/src/main/java/com/yahoo/documentapi/DocumentUpdateResponse.java
@@ -0,0 +1,82 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.documentapi;
+
+import com.yahoo.document.DocumentUpdate;
+
+/**
+ * The asynchronous response to a document update operation.
+ * This is a <i>value object</i>.
+ *
+ * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
+ */
+public class DocumentUpdateResponse extends Response {
+
+ /** The document update of this response, if any */
+ private DocumentUpdate documentUpdate = null;
+
+ /** Creates a successful response */
+ public DocumentUpdateResponse(long requestId) {
+ super(requestId);
+ }
+
+ /**
+ * Creates a successful response containing a document update
+ *
+ * @param documentUpdate the DocumentUpdate to encapsulate in the Response
+ */
+ public DocumentUpdateResponse(long requestId, DocumentUpdate documentUpdate) {
+ super(requestId);
+ this.documentUpdate = documentUpdate;
+ }
+
+ /**
+ * Creates a response containing a textual message
+ *
+ * @param textMessage the message to encapsulate in the Response
+ * @param success true if the response represents a successful call
+ */
+ public DocumentUpdateResponse(long requestId, String textMessage, boolean success) {
+ super(requestId, textMessage, success);
+ }
+
+ /**
+ * Creates a response containing a textual message and/or a document update
+ *
+ * @param documentUpdate the DocumentUpdate to encapsulate in the Response
+ * @param textMessage the message to encapsulate in the Response
+ * @param success true if the response represents a successful call
+ */
+ public DocumentUpdateResponse(long requestId, DocumentUpdate documentUpdate, String textMessage, boolean success) {
+ super(requestId, textMessage, success);
+ this.documentUpdate = documentUpdate;
+ }
+
+
+ /**
+ * Returns the document update of this response or null if there is none
+ *
+ * @return the DocumentUpdate, or null
+ */
+ public DocumentUpdate getDocumentUpdate() { return documentUpdate; }
+
+ public int hashCode() {
+ return super.hashCode() + (documentUpdate == null ? 0 : documentUpdate.hashCode());
+ }
+
+ public boolean equals(Object o) {
+ if (!(o instanceof DocumentUpdateResponse)) {
+ return false;
+ }
+
+ DocumentUpdateResponse docResp = (DocumentUpdateResponse) o;
+
+ return super.equals(docResp) && ((documentUpdate == null && docResp.documentUpdate == null) || (
+ documentUpdate != null && docResp.documentUpdate != null &&
+ documentUpdate.equals(docResp.documentUpdate)));
+ }
+
+ public String toString() {
+ return "Update" + super.toString() + (documentUpdate == null ? "" : " " + documentUpdate);
+ }
+
+}