@InterfaceStability.Experimental @InterfaceAudience.Public public class LookupResult extends Object
A result corresponding to a single LookupSpec
, usually grouped inside a MultiLookupResult
.
Modifier and Type | Method and Description |
---|---|
static LookupResult |
createExistResult(String path,
ResponseStatus status)
Create a
LookupResult that corresponds to a EXIST. |
static LookupResult |
createFatal(String path,
Lookup operation,
RuntimeException fatal)
Create a
LookupResult that denotes that a fatal Exception occurred when parsing server-side result. |
static LookupResult |
createGetResult(String path,
ResponseStatus status,
Object value)
Create a
LookupResult that corresponds to a GET. |
boolean |
exists() |
boolean |
isFatal() |
Lookup |
operation() |
String |
path() |
ResponseStatus |
status() |
Object |
value()
Returns: - the value retrieved by a successful GET.
|
Object |
valueOrThrow()
Returns: - the value retrieved by a successful GET.
|
public static LookupResult createFatal(String path, Lookup operation, RuntimeException fatal)
Create a LookupResult
that denotes that a fatal Exception occurred when parsing server-side result. The exception can be found as the value, and the status is ResponseStatus.FAILURE
.
path
- the path looked up.operation
- the lookup operation which result couldn’t be parsed.fatal
- the Exception that occurred during response parsing.public static LookupResult createGetResult(String path, ResponseStatus status, Object value)
Create a LookupResult
that corresponds to a GET.
path
- the path looked up.status
- the status of the GET.value
- the value of the GET if successful, null otherwise.public static LookupResult createExistResult(String path, ResponseStatus status)
Create a LookupResult
that corresponds to a EXIST.
path
- the path looked up.status
- the status of the EXIST, its isSuccess
giving the LookupResult’s value.public String path()
public Lookup operation()
public ResponseStatus status()
public boolean exists()
public Object value()
Returns: - the value retrieved by a successful GET. - null for an unsuccessful GET (see the status()
for details). - true/false for an EXIST (equivalent to exists()
). - a RuntimeException
if the client side parsing of the result failed (isFatal()
).
for a version that throws the exception instead of returning it.
public boolean isFatal()
value()
returns an RuntimeException
.public Object valueOrThrow()
Returns: - the value retrieved by a successful GET. - null for an unsuccessful GET (see the status()
for details). - true/false for an EXIST (equivalent to exists()
).
Throws: - a RuntimeException
if the client side parsing of the result failed (isFatal()
).
for a version that just returns the exception instead of throwing it.
Copyright © 2015 Couchbase, Inc.