P - The response type of a use case.Q - The request type of a use case.public abstract class UseCase<P,Q>
extends java.lang.Object
UseCase of the system orchestrate the flow of data to and from the entities.
Outer layers of system can execute use cases by calling execute(Object)} method. Also
you can use useCaseExecutor to execute the job in a background thread and postExecutionThread to post the result to another thread(usually UI thread).
| Constructor and Description |
|---|
UseCase(UseCaseExecutor useCaseExecutor,
PostExecutionThread postExecutionThread) |
| Modifier and Type | Method and Description |
|---|---|
abstract P |
execute(Q param)
Executes use case.
|
rx.Scheduler |
getPostExecutionThread() |
rx.Scheduler |
getUseCaseExecutor() |
protected abstract P |
interact(Q param)
A hook for interacting with the given parameter(request value) and returning a response value for
each concrete implementation.
|
public UseCase(UseCaseExecutor useCaseExecutor, PostExecutionThread postExecutionThread)
public abstract P execute(@Nullable Q param)
interact(Object) to get response value.protected abstract P interact(@Nullable Q param)
It should be called inside execute(Object).
param - The request value.public rx.Scheduler getUseCaseExecutor()
public rx.Scheduler getPostExecutionThread()