Added in API level 31

AppSearchResult

class AppSearchResult<ValueType : Any!>
kotlin.Any
   ↳ android.app.appsearch.AppSearchResult

Information about the success or failure of an AppSearch call.

Summary

Constants
static Int

An internal error occurred within AppSearch, which the caller cannot address.

static Int

The caller supplied invalid arguments to the call.

static Int

The caller supplied a schema which is invalid or incompatible with the previous schema.

static Int

An issue occurred reading or writing to storage.

static Int

An entity the caller requested to interact with does not exist in the system.

static Int

The call was successful.

static Int

Storage is out of space, and no more space could be reclaimed.

static Int

The caller requested an operation it does not have privileges for.

static Int

An unknown error occurred while processing the call.

Public methods
Boolean
equals(other: Any?)

Indicates whether some other object is "equal to" this one.

String?

Returns the error message associated with this result.

Int

Returns one of the RESULT constants defined in AppSearchResult.

ValueType?

Returns the result value associated with this result, if it was successful.

Int

Boolean

Returns true if getResultCode equals AppSearchResult#RESULT_OK.

static AppSearchResult<ValueType>
newFailedResult(resultCode: Int, errorMessage: String?)

Creates a new failed AppSearchResult.

static AppSearchResult<ValueType>
newSuccessfulResult(value: ValueType?)

Creates a new successful AppSearchResult.

String

Returns a string representation of the object.

Constants

RESULT_INTERNAL_ERROR

Added in API level 31
static val RESULT_INTERNAL_ERROR: Int

An internal error occurred within AppSearch, which the caller cannot address.

This error may be considered similar to IllegalStateException

Value: 2

RESULT_INVALID_ARGUMENT

Added in API level 31
static val RESULT_INVALID_ARGUMENT: Int

The caller supplied invalid arguments to the call.

This error may be considered similar to IllegalArgumentException.

Value: 3

RESULT_INVALID_SCHEMA

Added in API level 31
static val RESULT_INVALID_SCHEMA: Int

The caller supplied a schema which is invalid or incompatible with the previous schema.

Value: 7

RESULT_IO_ERROR

Added in API level 31
static val RESULT_IO_ERROR: Int

An issue occurred reading or writing to storage. The call might succeed if repeated.

This error may be considered similar to java.io.IOException.

Value: 4

RESULT_NOT_FOUND

Added in API level 31
static val RESULT_NOT_FOUND: Int

An entity the caller requested to interact with does not exist in the system.

Value: 6

RESULT_OK

Added in API level 31
static val RESULT_OK: Int

The call was successful.

Value: 0

RESULT_OUT_OF_SPACE

Added in API level 31
static val RESULT_OUT_OF_SPACE: Int

Storage is out of space, and no more space could be reclaimed.

Value: 5

RESULT_SECURITY_ERROR

Added in API level 31
static val RESULT_SECURITY_ERROR: Int

The caller requested an operation it does not have privileges for.

Value: 8

RESULT_UNKNOWN_ERROR

Added in API level 31
static val RESULT_UNKNOWN_ERROR: Int

An unknown error occurred while processing the call.

Value: 1

Public methods

equals

Added in API level 31
fun equals(other: Any?): Boolean

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj the reference object with which to compare.
other Any?: This value may be null.
Return
Boolean true if this object is the same as the obj argument; false otherwise.

getErrorMessage

Added in API level 31
fun getErrorMessage(): String?

Returns the error message associated with this result.

If isSuccess is true, the error message is always null. The error message may be null even if isSuccess is false. See the documentation of the particular AppSearchSession call producing this AppSearchResult for what is returned by getErrorMessage.

getResultValue

Added in API level 31
fun getResultValue(): ValueType?

Returns the result value associated with this result, if it was successful.

See the documentation of the particular AppSearchSession call producing this AppSearchResult for what is placed in the result value by that call.

Return
ValueType? This value may be null.
Exceptions
java.lang.IllegalStateException if this AppSearchResult is not successful.

hashCode

Added in API level 31
fun hashCode(): Int
Return
Int a hash code value for this object.

isSuccess

Added in API level 31
fun isSuccess(): Boolean

Returns true if getResultCode equals AppSearchResult#RESULT_OK.

newFailedResult

Added in API level 31
static fun <ValueType : Any!> newFailedResult(
    resultCode: Int,
    errorMessage: String?
): AppSearchResult<ValueType>

Creates a new failed AppSearchResult.

Parameters
resultCode Int: One of the constants documented in AppSearchResult#getResultCode. Value is android.app.appsearch.AppSearchResult#RESULT_OK, android.app.appsearch.AppSearchResult#RESULT_UNKNOWN_ERROR, android.app.appsearch.AppSearchResult#RESULT_INTERNAL_ERROR, android.app.appsearch.AppSearchResult#RESULT_INVALID_ARGUMENT, android.app.appsearch.AppSearchResult#RESULT_IO_ERROR, android.app.appsearch.AppSearchResult#RESULT_OUT_OF_SPACE, android.app.appsearch.AppSearchResult#RESULT_NOT_FOUND, android.app.appsearch.AppSearchResult#RESULT_INVALID_SCHEMA, android.app.appsearch.AppSearchResult#RESULT_SECURITY_ERROR, android.app.appsearch.AppSearchResult.RESULT_DENIED, or android.app.appsearch.AppSearchResult.RESULT_RATE_LIMITED
errorMessage String?: An optional string describing the reason or nature of the failure. This value may be null.
Return
AppSearchResult<ValueType> This value cannot be null.

newSuccessfulResult

Added in API level 31
static fun <ValueType : Any!> newSuccessfulResult(value: ValueType?): AppSearchResult<ValueType>

Creates a new successful AppSearchResult.

Parameters
value ValueType?: An optional value to associate with the successful result of the operation being performed. This value may be null.
Return
AppSearchResult<ValueType> This value cannot be null.

toString

Added in API level 31
fun toString(): String

Returns a string representation of the object.

Return
String This value cannot be null.