1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.documentapi;
import com.yahoo.document.DocumentId;
import com.yahoo.messagebus.Trace;
/**
* The asynchronous response to a document remove operation.
* This is a <i>value object</i>.
*
* @author Einar M R Rosenvinge
*/
public class DocumentIdResponse extends Response {
/** The document id of this response, if any */
private final DocumentId documentId;
/** Creates a successful response */
public DocumentIdResponse(long requestId) {
this(requestId, null);
}
/**
* Creates a successful response containing a document id
*
* @param documentId the DocumentId to encapsulate in the Response
*/
public DocumentIdResponse(long requestId, DocumentId documentId) {
super(requestId);
this.documentId = documentId;
}
/**
* Creates a response containing a textual message and/or a document id
*
* @param documentId the DocumentId to encapsulate in the Response
* @param textMessage the message to encapsulate in the Response
* @param outcome the outcome of the operation
*/
public DocumentIdResponse(long requestId, DocumentId documentId, String textMessage, Outcome outcome) {
this(requestId, documentId, textMessage, outcome, null);
}
/**
* Creates a response containing a textual message and/or a document id
*
* @param documentId the DocumentId to encapsulate in the Response
* @param textMessage the message to encapsulate in the Response
* @param outcome the outcome of the operation
*/
public DocumentIdResponse(long requestId, DocumentId documentId, String textMessage, Outcome outcome, Trace trace) {
super(requestId, textMessage, outcome, null);
this.documentId = documentId;
}
/**
* Returns the document id of this response, or null if there is none
*
* @return the DocumentId, or null
*/
public DocumentId getDocumentId() { return documentId; }
public int hashCode() {
return super.hashCode() + (documentId == null ? 0 : documentId.hashCode());
}
public boolean equals(Object o) {
if (!(o instanceof DocumentIdResponse)) {
return false;
}
DocumentIdResponse docResp = (DocumentIdResponse) o;
return super.equals(docResp) && ((documentId == null && docResp.documentId == null) ||
(documentId != null && docResp.documentId != null && documentId.equals(docResp.documentId)));
}
public String toString() {
return "DocumentId" + super.toString() + (documentId == null ? "" : " " + documentId);
}
}
|