Files
vod-system/src/main/java/com/ddf/vodsystem/dto/ProgressTracker.java
Dylan De Faoite e8c57f119c
All checks were successful
CI / Maven unit tests (push) Successful in 14s
CI / Build and push images (push) Has been skipped
CI / Deploy to server (push) Has been skipped
add docstrings to everything
2026-08-23 02:57:50 +01:00

53 lines
1.3 KiB
Java

package com.ddf.vodsystem.dto;
public class ProgressTracker {
private float progress = 0.0f;
private boolean isComplete = false;
/**
* Returns the current progress.
*
* @return the progress as a fraction in {@code [0, 1]}
*/
public synchronized float getProgress() {
return progress;
}
/**
* Returns whether the tracked task has been marked complete.
*
* @return {@code true} if complete
*/
public synchronized boolean isComplete() {
return isComplete;
}
/**
* Updates the current progress.
*
* @param newProgress the progress as a fraction in {@code [0, 1]}
* @throws IllegalArgumentException if {@code newProgress} is outside {@code [0, 1]}
*/
public synchronized void setProgress(float newProgress) {
if (newProgress < 0 || newProgress > 1) {
throw new IllegalArgumentException("Progress must be between 0 and 1");
}
this.progress = newProgress;
}
/**
* Marks the tracked task as complete.
*/
public synchronized void markComplete() {
this.isComplete = true;
}
/**
* Resets progress to zero and clears the complete flag.
*/
public synchronized void reset() {
this.progress = 0.0f;
this.isComplete = false;
}
}