WorkQuery.Builder


public final class WorkQuery.Builder


A builder for WorkQuery.

Summary

Public methods

final @NonNull WorkQuery.Builder

Adds a List of WorkRequest ids to the WorkQuery

final @NonNull WorkQuery.Builder

Adds a List of WorkInfo.States to the WorkQuery.

final @NonNull WorkQuery.Builder

Adds a List of WorkRequest tag to the WorkQuery.

final @NonNull WorkQuery.Builder

Adds a List of uniqueWorkNames to the WorkQuery

final @NonNull WorkQuery

Creates an instance of WorkQuery.

static final @NonNull WorkQuery.Builder

Creates a WorkQuery.Builder with a List of WorkRequest ids.

static final @NonNull WorkQuery.Builder

Creates a WorkQuery.Builder with a List of WorkInfo.State states.

static final @NonNull WorkQuery.Builder

Creates a WorkQuery.Builder with a List of WorkRequest tags.

static final @NonNull WorkQuery.Builder

Creates a WorkQuery.Builder with a List of uniqueWorkNames.

Public methods

addIds

Added in 2.5.0
public final @NonNull WorkQuery.Builder addIds(@NonNull List<@NonNull UUID> ids)

Adds a List of WorkRequest ids to the WorkQuery

Parameters
@NonNull List<@NonNull UUID> ids

The List ids to add

Returns
@NonNull WorkQuery.Builder

the instance of the Builder

addStates

Added in 2.4.0
public final @NonNull WorkQuery.Builder addStates(@NonNull List<@NonNull WorkInfo.State> states)

Adds a List of WorkInfo.States to the WorkQuery.

Parameters
@NonNull List<@NonNull WorkInfo.State> states

The List of WorkInfo.States to add

Returns
@NonNull WorkQuery.Builder

the instance of the Builder

addTags

Added in 2.4.0
public final @NonNull WorkQuery.Builder addTags(@NonNull List<@NonNull String> tags)

Adds a List of WorkRequest tag to the WorkQuery.

Parameters
@NonNull List<@NonNull String> tags

The List of WorkRequest tags to add

Returns
@NonNull WorkQuery.Builder

the instance of the Builder

addUniqueWorkNames

Added in 2.4.0
public final @NonNull WorkQuery.Builder addUniqueWorkNames(@NonNull List<@NonNull String> uniqueWorkNames)

Adds a List of uniqueWorkNames to the WorkQuery

Parameters
@NonNull List<@NonNull String> uniqueWorkNames

The List of unique work names to add

Returns
@NonNull WorkQuery.Builder

the instance of the Builder

build

Added in 2.4.0
public final @NonNull WorkQuery build()

Creates an instance of WorkQuery.

Returns
@NonNull WorkQuery

the WorkQuery instance

Throws
kotlin.IllegalArgumentException

if neither of ids, uniqueWorkNames, tags or states is set.

fromIds

Added in 2.10.0-rc01
public static final @NonNull WorkQuery.Builder fromIds(@NonNull List<@NonNull UUID> ids)

Creates a WorkQuery.Builder with a List of WorkRequest ids.

Parameters
@NonNull List<@NonNull UUID> ids

The List of WorkRequest ids.

Returns
@NonNull WorkQuery.Builder

a Builder instance

fromStates

public static final @NonNull WorkQuery.Builder fromStates(@NonNull List<@NonNull WorkInfo.State> states)

Creates a WorkQuery.Builder with a List of WorkInfo.State states.

Parameters
@NonNull List<@NonNull WorkInfo.State> states

The List of WorkInfo.State to add to the WorkQuery

Returns
@NonNull WorkQuery.Builder

a Builder instance

fromTags

Added in 2.10.0-rc01
public static final @NonNull WorkQuery.Builder fromTags(@NonNull List<@NonNull String> tags)

Creates a WorkQuery.Builder with a List of WorkRequest tags.

Parameters
@NonNull List<@NonNull String> tags

The List of WorkRequest tags

Returns
@NonNull WorkQuery.Builder

a Builder instance

fromUniqueWorkNames

Added in 2.10.0-rc01
public static final @NonNull WorkQuery.Builder fromUniqueWorkNames(@NonNull List<@NonNull String> uniqueWorkNames)

Creates a WorkQuery.Builder with a List of uniqueWorkNames.

Parameters
@NonNull List<@NonNull String> uniqueWorkNames

The List of unique work names

Returns
@NonNull WorkQuery.Builder

a Builder instance