Skip to content

Instantly share code, notes, and snippets.

@Jire
Created July 24, 2011 03:55
Show Gist options
  • Save Jire/1102214 to your computer and use it in GitHub Desktop.
Save Jire/1102214 to your computer and use it in GitHub Desktop.
Used to contain attributes for jobs which should be client-configured.
package us.ironbase.job;
/**
* Used to contain attributes for {@link Job}s which should be
* client-configured.
*
* @author Thomas Nappo
*/
class JobLegacy {
/**
* The job who parents the legacy.
*/
private final Job parent;
/**
* The scheduler which called for the creation of the legacy.
*/
private final Scheduler scheduler;
/**
* The time interval in milliseconds between each execution of the {@link #job}.
*/
private int rate;
/**
* Constructs a new job legacy.
* @param parent The job who parents the legacy.
* @param scheduler The scheduler which called it's creation.
*/
public JobLegacy(Job parent, Scheduler scheduler) {
this.parent = parent;
this.scheduler = scheduler;
}
/**
* Retrieves the legacy's {@link #parent} job.
* @return The job who parents the legacy.
*/
protected Job getParent() {
return parent;
}
/**
* Retrieves the legacy's {@link #scheduler}.
* @return The scheduler which called it's creation.
*/
protected Scheduler getScheduler() {
return scheduler;
}
/**
* Retrieves the legacy's {@link #rate}.
* @return The time interval in milliseconds between each execution of the {@link #job}.
*/
protected int getRate() {
return rate;
}
/**
* Sets the legacy's {@link #rate} and then uses it's {@link #scheduler}
* to schedule the {@link #job} to be ran at the specified time interval.
* @param millis The time interval in milliseconds between each execution of the job.
*/
public void atRate(int millis) {
rate = millis;
scheduler.schedule(this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment