public class ProgressTracker
A progress tracker helps surface information about the progress of an operation to a user interface or API of some kind. It lets you define a set of steps that represent an operation. A step is represented by an object (typically a singleton).
Steps may logically be children of other steps, which models the case where a large top level operation involves sub-operations which may also have a notion of progress. If a step has children, then the tracker will report the steps children as the "next step" after the parent. In other words, a parent step is considered to involve actual reportable work and is a thing. If the parent step simply groups other steps, then you'll have to step over it manually.
Each step has a label. It is assumed by default that the label does not change. If you want a label to change, then
you can emit a class Change.Rendering
object on the ProgressTracker.Step.getChanges
observable stream
after it changes. That object will propagate through to the top level trackers ProgressTracker.getChanges
stream, which renderers can
subscribe to in order to learn about progress.
An operation can move both forwards and backwards through steps, thus, a class ProgressTracker
can represent operations
that include loops.
A progress tracker is not thread safe. You may move events from the thread making progress to another thread by using the Observable subscribeOn call.
Modifier and Type | Class and Description |
---|---|
static class |
ProgressTracker.Change |
static class |
ProgressTracker.DONE |
static class |
ProgressTracker.STARTING |
static class |
ProgressTracker.Step
The superclass of all step objects.
|
static class |
ProgressTracker.UNSTARTED |
Modifier and Type | Field and Description |
---|---|
static net.corda.core.utilities.ProgressTracker.Companion |
Companion
Deprecated.
|
Constructor and Description |
---|
ProgressTracker(net.corda.core.utilities.ProgressTracker.Step inputSteps)
A progress tracker helps surface information about the progress of an operation to a user interface or API of some
kind. It lets you define a set of steps that represent an operation. A step is represented by an object (typically
a singleton).
|
Modifier and Type | Method and Description |
---|---|
void |
endWithError(java.lang.Throwable error)
Ends the progress tracker with the given error, bypassing any remaining steps.
ProgressTracker.getChanges will emit the exception
as an error. |
java.util.List<NonExistentClass> |
getAllSteps()
A list of all steps in this ProgressTracker and the children, with the indent level provided starting at zero.
Note that UNSTARTED is never counted, and DONE is only counted at the calling level.
|
java.util.List<NonExistentClass> |
getAllStepsLabels()
A list of all steps label in this ProgressTracker and the children, with the indent level provided starting at zero.
Note that UNSTARTED is never counted, and DONE is only counted at the calling level.
|
NonExistentClass |
getChanges()
An observable stream of changes: includes child steps, resets and any changes emitted by individual steps (e.g.
if a step changed its label or rendering).
|
ProgressTracker |
getChildProgressTracker(ProgressTracker.Step step) |
ProgressTracker.Step |
getCurrentStep()
Reading returns the value of steps
ProgressTracker.getStepIndex , writing moves the position of the current tracker. Once moved to
the class ProgressTracker.DONE state, this tracker is finished and the current step cannot be moved again. |
ProgressTracker.Step |
getCurrentStepRecursive()
Returns the current step, descending into children to find the deepest step we are up to.
|
boolean |
getHasEnded()
Returns true if the progress tracker has ended, either by reaching the
class ProgressTracker.DONE step or prematurely with an error |
ProgressTracker |
getParent()
The parent of this tracker: set automatically by the parent when a tracker is added as a child
|
int |
getStepIndex()
The zero-based index of the current step in the
ProgressTracker.getSteps array (i.e. with UNSTARTED and DONE) |
NonExistentClass |
getSteps()
The steps in this tracker, same as the steps passed to the constructor but with UNSTARTED and DONE inserted.
|
NonExistentClass |
getStepsTreeChanges()
An observable stream of changes to the
ProgressTracker.getAllStepsLabels |
int |
getStepsTreeIndex()
The zero-bases index of the current step in a
ProgressTracker.getAllStepsLabels list |
NonExistentClass |
getStepsTreeIndexChanges()
An observable stream of changes to the
ProgressTracker.getStepsTreeIndex |
ProgressTracker |
getTopLevelTracker()
Walks up the tree to find the top level tracker. If this is the top level tracker, returns 'this'.
Required for API compatibility.
|
ProgressTracker.Step |
nextStep()
Iterates the progress tracker. If the current step has a child, the child is iterated instead (recursively).
Returns the latest step at the bottom of the step tree.
|
void |
setChildProgressTracker(ProgressTracker.Step step,
ProgressTracker childProgressTracker) |
void |
setCurrentStep(ProgressTracker.Step value)
Reading returns the value of steps
ProgressTracker.getStepIndex , writing moves the position of the current tracker. Once moved to
the class ProgressTracker.DONE state, this tracker is finished and the current step cannot be moved again. |
public static net.corda.core.utilities.ProgressTracker.Companion Companion
public ProgressTracker(net.corda.core.utilities.ProgressTracker.Step inputSteps)
A progress tracker helps surface information about the progress of an operation to a user interface or API of some kind. It lets you define a set of steps that represent an operation. A step is represented by an object (typically a singleton).
Steps may logically be children of other steps, which models the case where a large top level operation involves sub-operations which may also have a notion of progress. If a step has children, then the tracker will report the steps children as the "next step" after the parent. In other words, a parent step is considered to involve actual reportable work and is a thing. If the parent step simply groups other steps, then you'll have to step over it manually.
Each step has a label. It is assumed by default that the label does not change. If you want a label to change, then
you can emit a class Change.Rendering
object on the ProgressTracker.Step.getChanges
observable stream
after it changes. That object will propagate through to the top level trackers ProgressTracker.getChanges
stream, which renderers can
subscribe to in order to learn about progress.
An operation can move both forwards and backwards through steps, thus, a class ProgressTracker
can represent operations
that include loops.
A progress tracker is not thread safe. You may move events from the thread making progress to another thread by using the Observable subscribeOn call.
public NonExistentClass getSteps()
The steps in this tracker, same as the steps passed to the constructor but with UNSTARTED and DONE inserted.
public ProgressTracker.Step getCurrentStep()
Reading returns the value of stepsProgressTracker.getStepIndex
, writing moves the position of the current tracker. Once moved to
the class ProgressTracker.DONE
state, this tracker is finished and the current step cannot be moved again.
public void setCurrentStep(ProgressTracker.Step value)
Reading returns the value of stepsProgressTracker.getStepIndex
, writing moves the position of the current tracker. Once moved to
the class ProgressTracker.DONE
state, this tracker is finished and the current step cannot be moved again.
public int getStepIndex()
The zero-based index of the current step in the ProgressTracker.getSteps
array (i.e. with UNSTARTED and DONE)
ProgressTracker.getSteps
public int getStepsTreeIndex()
The zero-bases index of the current step in a ProgressTracker.getAllStepsLabels
list
ProgressTracker.getAllStepsLabels
public ProgressTracker.Step getCurrentStepRecursive()
Returns the current step, descending into children to find the deepest step we are up to.
public ProgressTracker getChildProgressTracker(ProgressTracker.Step step)
public void setChildProgressTracker(ProgressTracker.Step step, ProgressTracker childProgressTracker)
public void endWithError(java.lang.Throwable error)
Ends the progress tracker with the given error, bypassing any remaining steps. ProgressTracker.getChanges
will emit the exception
as an error.
ProgressTracker.getChanges
public ProgressTracker getParent()
The parent of this tracker: set automatically by the parent when a tracker is added as a child
public ProgressTracker getTopLevelTracker()
Walks up the tree to find the top level tracker. If this is the top level tracker, returns 'this'. Required for API compatibility.
public java.util.List<NonExistentClass> getAllSteps()
A list of all steps in this ProgressTracker and the children, with the indent level provided starting at zero. Note that UNSTARTED is never counted, and DONE is only counted at the calling level.
public java.util.List<NonExistentClass> getAllStepsLabels()
A list of all steps label in this ProgressTracker and the children, with the indent level provided starting at zero. Note that UNSTARTED is never counted, and DONE is only counted at the calling level.
public ProgressTracker.Step nextStep()
Iterates the progress tracker. If the current step has a child, the child is iterated instead (recursively). Returns the latest step at the bottom of the step tree.
public NonExistentClass getChanges()
An observable stream of changes: includes child steps, resets and any changes emitted by individual steps (e.g. if a step changed its label or rendering).
public NonExistentClass getStepsTreeChanges()
An observable stream of changes to the ProgressTracker.getAllStepsLabels
ProgressTracker.getAllStepsLabels
public NonExistentClass getStepsTreeIndexChanges()
An observable stream of changes to the ProgressTracker.getStepsTreeIndex
ProgressTracker.getStepsTreeIndex
public boolean getHasEnded()
Returns true if the progress tracker has ended, either by reaching the class ProgressTracker.DONE
step or prematurely with an error
class ProgressTracker.DONE