blob: c74d81730eea1cb214f91653ee863f169bd10c67 (
plain) (
blame)
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.persistence.spi.result;
import com.yahoo.document.Document;
/**
* Result class for Get operations
*/
public class GetResult extends Result {
Document doc;
long lastModifiedTimestamp = 0;
/**
* Constructor to use when there was an error retrieving the document.
* Not finding the document is not an error in this context.
*
* @param type The type of error.
* @param message A human readable message further detailing the error.
*/
GetResult(ErrorType type, String message) {
super(type, message);
}
/**
* Constructor to use when we didn't find the document in question.
*/
public GetResult() {}
/**
* Constructor to use when we found the document asked for.
*
* @param doc The document we found
* @param lastModifiedTimestamp The timestamp with which the document was stored.
*/
public GetResult(Document doc, long lastModifiedTimestamp) {
this.doc = doc;
this.lastModifiedTimestamp = lastModifiedTimestamp;
}
/**
* @return Returns the timestamp at which the document was last modified, or 0 if
* no document was found.
*/
public long getLastModifiedTimestamp() { return lastModifiedTimestamp;}
/**
* @return Returns true if the document was found.
*/
public boolean wasFound() {
return doc != null;
}
public boolean hasDocument() {
return doc != null;
}
public Document getDocument() {
return doc;
}
}
|