diff --git a/computer-driver/src/main/java/org/apache/hugegraph/computer/driver/DefaultJobState.java b/computer-driver/src/main/java/org/apache/hugegraph/computer/driver/DefaultJobState.java index bda3fe15a..0ae4ba6bb 100644 --- a/computer-driver/src/main/java/org/apache/hugegraph/computer/driver/DefaultJobState.java +++ b/computer-driver/src/main/java/org/apache/hugegraph/computer/driver/DefaultJobState.java @@ -19,6 +19,11 @@ import java.util.Objects; +/** + * DefaultJobState is an implementation of the JobState interface. + * It holds the state of a job including the current superstep, + * the maximum superstep, the last superstep statistics, and the job status. + */ public class DefaultJobState implements JobState { private int superstep; @@ -26,46 +31,83 @@ public class DefaultJobState implements JobState { private SuperstepStat lastSuperstepStat; private JobStatus jobStatus; + /** + * Sets the current superstep. + * @param superstep The current superstep. + * @return The updated DefaultJobState instance. + */ public DefaultJobState superstep(int superstep) { this.superstep = superstep; return this; } + /** + * Sets the maximum superstep. + * @param maxSuperstep The maximum superstep. + * @return The updated DefaultJobState instance. + */ public DefaultJobState maxSuperstep(int maxSuperstep) { this.maxSuperstep = maxSuperstep; return this; } + /** + * Sets the last superstep statistics. + * @param lastSuperstepStat The last superstep statistics. + * @return The updated DefaultJobState instance. + */ public DefaultJobState lastSuperstepStat(SuperstepStat lastSuperstepStat) { this.lastSuperstepStat = lastSuperstepStat; return this; } + /** + * Sets the job status. + * @param jobStatus The job status. + * @return The updated DefaultJobState instance. + */ public DefaultJobState jobStatus(JobStatus jobStatus) { this.jobStatus = jobStatus; return this; } + /** + * @return The current superstep. + */ @Override public int superstep() { return this.superstep; } + /** + * @return The maximum superstep. + */ @Override public int maxSuperstep() { return this.maxSuperstep; } + /** + * @return The last superstep statistics. + */ @Override public SuperstepStat lastSuperstepStat() { return this.lastSuperstepStat; } + /** + * @return The job status. + */ @Override public JobStatus jobStatus() { return this.jobStatus; } + /** + * Checks if the given object is equal to this instance. + * @param o The object to compare with. + * @return true if the given object is equal to this instance, false otherwise. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -74,24 +116,30 @@ public boolean equals(Object o) { if (!(o instanceof DefaultJobState)) { return false; } + DefaultJobState jobState = (DefaultJobState) o; return this.superstep == jobState.superstep && this.maxSuperstep == jobState.maxSuperstep && - Objects.equals(this.lastSuperstepStat, - jobState.lastSuperstepStat) && + Objects.equals(this.lastSuperstepStat, jobState.lastSuperstepStat) && this.jobStatus == jobState.jobStatus; } + /** + * @return The hash code of this instance. + */ @Override public int hashCode() { return Objects.hash(this.superstep, this.maxSuperstep, this.lastSuperstepStat, this.jobStatus); } + /** + * @return A string representation of this instance. + */ @Override public String toString() { - return String.format("%s[superstep=%s, maxSuperStep=%s, lastSuperstepStat=%s, - jobStatus=%s]", DefaultJobState.class.getSimpleName(), + return String.format("%s[superstep=%s, maxSuperStep=%s, lastSuperstepStat=%s, " + + "jobStatus=%s]", DefaultJobState.class.getSimpleName(), superstep, maxSuperstep, lastSuperstepStat, jobStatus); } }