BackupDeviceActionResult


public final class BackupDeviceActionResult


Results returned from a BackupDeviceAction back to the host orchestrator.

BackupActionOutputKeys documents every key the actions bundled with this library produce. Actions built with success and failure always report BackupActionOutputKeys.STATUS, and report BackupActionOutputKeys.ERROR only alongside a failure. Additional keys may be returned to carry data back to the host, which forwards the whole payload to the caller.

Summary

Public constructors

Public methods

boolean
equals(Object other)
static final @NonNull BackupDeviceActionResult
failure(
    @NonNull String errorMessage,
    @NonNull Map<@NonNull String, @NonNull String> payload
)

Returns a result reporting BackupActionValues.STATUS_FAILURE together with errorMessage.

final String

Returns the result stored under key, or null when the action did not produce it.

final String

The reported BackupActionOutputKeys.ERROR, or null when the action did not fail.

final @NonNull Map<@NonNull String, @NonNull String>

key-value results produced by the action, keyed by BackupActionOutputKeys

final String

The reported BackupActionOutputKeys.STATUS, or null for an action that does not report one.

int
final boolean

Whether the action completed its work.

static final @NonNull BackupDeviceActionResult

Returns a result reporting BackupActionValues.STATUS_SUCCESS.

@NonNull String

Public constructors

BackupDeviceActionResult

Added in 1.0.0-alpha02
public BackupDeviceActionResult(
    @NonNull Map<@NonNull String, @NonNull String> payload
)

Public methods

equals

public boolean equals(Object other)

failure

Added in 1.0.0-alpha02
public static final @NonNull BackupDeviceActionResult failure(
    @NonNull String errorMessage,
    @NonNull Map<@NonNull String, @NonNull String> payload
)

Returns a result reporting BackupActionValues.STATUS_FAILURE together with errorMessage.

Parameters
@NonNull String errorMessage

human-readable description of the failure, surfaced to the host as BackupActionOutputKeys.ERROR

@NonNull Map<@NonNull String, @NonNull String> payload

additional data to return to the host; BackupActionOutputKeys.STATUS and BackupActionOutputKeys.ERROR entries it contains are overwritten

get

Added in 1.0.0-alpha02
public final String get(@NonNull String key)

Returns the result stored under key, or null when the action did not produce it.

Any key may be read, so a custom BackupDeviceAction can return keys of its own alongside the BackupActionOutputKeys constants.

getErrorMessage

Added in 1.0.0-alpha02
public final String getErrorMessage()

The reported BackupActionOutputKeys.ERROR, or null when the action did not fail.

Reported only for a result that isSuccess rejects. A successful action may legitimately carry a BackupActionOutputKeys.ERROR entry of its own — an empty string, or a diagnostic unrelated to the outcome — and surfacing that as a failure message would be misleading. This mirrors the host, which reads the key under exactly the same conditions.

See also
isSuccess

getPayload

Added in 1.0.0-alpha02
public final @NonNull Map<@NonNull String, @NonNull String> getPayload()

key-value results produced by the action, keyed by BackupActionOutputKeys

getStatus

Added in 1.0.0-alpha02
public final String getStatus()

The reported BackupActionOutputKeys.STATUS, or null for an action that does not report one.

hashCode

public int hashCode()

isSuccess

Added in 1.0.0-alpha02
public final boolean isSuccess()

Whether the action completed its work.

Resolved in two steps:

  • A reported BackupActionOutputKeys.STATUS decides on its own. Only BackupActionValues.STATUS_FAILURE, compared without regard to case, means failure; status is a generic key that custom actions also use to publish their own vocabulary, so an unrecognized value is reported as successful rather than being guessed at.

  • With no status at all, a non-empty BackupActionOutputKeys.ERROR means failure. An action that reports only an error would otherwise be read as passing.

Use BackupDeviceActionResult.failure to report a failure that callers and the host will honor.

success

Added in 1.0.0-alpha02
public static final @NonNull BackupDeviceActionResult success(@NonNull Map<@NonNull String, @NonNull String> payload)

Returns a result reporting BackupActionValues.STATUS_SUCCESS.

Parameters
@NonNull Map<@NonNull String, @NonNull String> payload

additional data to return to the host; a BackupActionOutputKeys.STATUS entry it contains is overwritten

toString

public @NonNull String toString()