Skip to content

Commit

Permalink
Update DefaultJobState.java
Browse files Browse the repository at this point in the history
  • Loading branch information
imbajin committed Dec 4, 2023
1 parent 9b008b7 commit 1133673
Showing 1 changed file with 52 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,95 @@

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;
private int maxSuperstep;
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) {
Expand All @@ -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);
}
}

0 comments on commit 1133673

Please sign in to comment.