
com.octo.android.robospice.priority.PriorityFuture Maven / Gradle / Ivy
package com.octo.android.robospice.priority;
import java.util.concurrent.FutureTask;
/**
* A future with priority, from SOF
* @author SNI
* @param
* the type of the future's return.
*/
public class PriorityFuture extends FutureTask implements Comparable> {
private int priority;
public PriorityFuture(Runnable other, int priority, final T result) {
super(other, result);
this.priority = priority;
}
public int getPriority() {
return priority;
}
@Override
public int compareTo(PriorityFuture other) {
return priority - other.priority;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + priority;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
PriorityFuture> other = (PriorityFuture>) obj;
if (priority != other.priority) {
return false;
}
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy