Package org.reldb.toolbox.progress
Class StandardProgressIndicator
java.lang.Object
org.reldb.toolbox.progress.StandardProgressIndicator
- All Implemented Interfaces:
ProgressIndicator
- Direct Known Subclasses:
ConsoleProgressIndicator
A ProgressIndicator that generates and outputs progress updates via specified lambda expressions.
-
Constructor Summary
ConstructorDescriptionStandardProgressIndicator(String messagePrefix, ProgressIndicatorDisplay display, ProgressIndicatorMessage messageGenerator)
Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGet the most recent non-null additional information.Get the message prefix.float
Get percent progress as a float.int
Get the current indicator position.int
Get progress message percent precision.Get the current progress as a percentage.int
getSteps()
Get the number of steps.void
initialise(int steps)
Initialise the indicator with the number of steps.void
Move the indicator to the given 0-based step.void
setPrecision(int precision)
Set progress message percent precision.
-
Constructor Details
-
StandardProgressIndicator
public StandardProgressIndicator(String messagePrefix, ProgressIndicatorDisplay display, ProgressIndicatorMessage messageGenerator)Constructor.- Parameters:
messagePrefix
- This will be prefixed to all outputted messages.display
- Lambda definition of display mechanism.messageGenerator
- Lambda definition of message generator.
-
-
Method Details
-
setPrecision
public void setPrecision(int precision)Set progress message percent precision.- Parameters:
precision
- Decimal precision of percentage. Default is 2 decimal places.
-
getPrecision
public int getPrecision()Get progress message percent precision.- Returns:
- Decimal precision of percentage. Default is 2 decimal places.
-
getMessagePrefix
Get the message prefix. Set in the constructor.- Returns:
- The message prefix.
-
getPosition
public int getPosition()Description copied from interface:ProgressIndicator
Get the current indicator position.- Specified by:
getPosition
in interfaceProgressIndicator
- Returns:
- Current indicator position.
-
getLastMessage
Description copied from interface:ProgressIndicator
Get the most recent non-null additional information.- Specified by:
getLastMessage
in interfaceProgressIndicator
- Returns:
- Most recent non-null additional information string.
-
getPercent
public float getPercent()Get percent progress as a float.- Returns:
- Percent progress.
-
initialise
public void initialise(int steps)Description copied from interface:ProgressIndicator
Initialise the indicator with the number of steps.- Specified by:
initialise
in interfaceProgressIndicator
- Parameters:
steps
- Number of steps or -1 if unknown. Should be non-zero.
-
getSteps
public int getSteps()Description copied from interface:ProgressIndicator
Get the number of steps. Set via initialise(...)- Specified by:
getSteps
in interfaceProgressIndicator
- Returns:
- The total number of steps; -1 if unknown.
-
getProgressMessage
Get the current progress as a percentage.- Returns:
- Current progress message.
-
move
Description copied from interface:ProgressIndicator
Move the indicator to the given 0-based step. additionalInformation supplies additional progress text; null if not needed.- Specified by:
move
in interfaceProgressIndicator
- Parameters:
step
- Move the indicator to this step number.additionalInformation
- Provide optional additional information about this step.
-