Package me.tongfei.progressbar
Class DefaultProgressBarRenderer
java.lang.Object
me.tongfei.progressbar.DefaultProgressBarRenderer
- All Implemented Interfaces:
ProgressBarRenderer
Default progress bar renderer (see
ProgressBarRenderer).- Since:
- 0.8.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Function<ProgressState, Optional<Duration>> private booleanprivate booleanprivate DecimalFormatprivate ChronoUnitprivate ProgressBarStyleprivate Stringprivate long -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefaultProgressBarRenderer(ProgressBarStyle style, String unitName, long unitSize, boolean isSpeedShown, DecimalFormat speedFormat, ChronoUnit speedUnit, boolean isEtaShown, Function<ProgressState, Optional<Duration>> eta) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringetaString(ProgressState progress) protected Stringpercentage(ProgressState progress) protected intprogressFractionalPart(ProgressState progress, int length) protected intprogressIntegralPart(ProgressState progress, int length) protected Stringratio(ProgressState progress) render(ProgressState progress, int maxLength) Renders the current progress bar state as a string to be shown by a consumer.protected Stringspeed(ProgressState progress)
-
Field Details
-
style
-
unitName
-
unitSize
private long unitSize -
isSpeedShown
private boolean isSpeedShown -
speedFormat
-
speedUnit
-
isEtaShown
private boolean isEtaShown -
eta
-
-
Constructor Details
-
DefaultProgressBarRenderer
protected DefaultProgressBarRenderer(ProgressBarStyle style, String unitName, long unitSize, boolean isSpeedShown, DecimalFormat speedFormat, ChronoUnit speedUnit, boolean isEtaShown, Function<ProgressState, Optional<Duration>> eta)
-
-
Method Details
-
progressIntegralPart
-
progressFractionalPart
-
etaString
-
percentage
-
ratio
-
speed
-
render
Description copied from interface:ProgressBarRendererRenders the current progress bar state as a string to be shown by a consumer.- Specified by:
renderin interfaceProgressBarRenderer- Parameters:
progress- The current progress bar statemaxLength- The maximum length as dictated by the consumer- Returns:
- Rendered string to be consumed by the consumer
-