GP-3597 add methods to combine calling increment and checkCancelled, etc

Add methods to combine calling increment+checkCancelled andinitialize+setMessage
This commit is contained in:
dev747368 2023-06-30 11:05:23 -04:00
parent d2be76feb7
commit 8bc28b02d9

View file

@ -88,6 +88,17 @@ public interface TaskMonitor {
*/ */
public void initialize(long max); public void initialize(long max);
/**
* Initializes the progress value to 0, sets the max value and message of this monitor.
*
* @param max maximum value for progress
* @param message the message to display
*/
default public void initialize(long max, String message) {
initialize(max);
setMessage(message);
}
/** /**
* Set the progress maximum value * Set the progress maximum value
* <p><b> * <p><b>
@ -133,11 +144,41 @@ public interface TaskMonitor {
} }
/** /**
* A convenience method to increment the current progress by the given value * Increases the progress value by 1.
*/
default public void incrementProgress() {
incrementProgress(1);
}
/**
* Changes the progress value by the specified amount.
*
* @param incrementAmount The amount by which to increment the progress * @param incrementAmount The amount by which to increment the progress
*/ */
public void incrementProgress(long incrementAmount); public void incrementProgress(long incrementAmount);
/**
* Increases the progress value by 1, and checks if this monitor has been cancelled.
*
* @throws CancelledException if monitor has been cancelled
*/
default public void increment() throws CancelledException {
checkCancelled();
incrementProgress(1);
}
/**
* Changes the progress value by the specified amount, and checks if this monitor has
* been cancelled.
*
* @param incrementAmount The amount by which to increment the progress
* @throws CancelledException if monitor has been cancelled
*/
default public void increment(long incrementAmount) throws CancelledException {
checkCancelled();
incrementProgress(incrementAmount);
}
/** /**
* Returns the current progress value or {@link #NO_PROGRESS_VALUE} if there is no value set * Returns the current progress value or {@link #NO_PROGRESS_VALUE} if there is no value set
* @return the current progress value or {@link #NO_PROGRESS_VALUE} if there is no value set * @return the current progress value or {@link #NO_PROGRESS_VALUE} if there is no value set