public int compare(final ContextRunnable r1, final ContextRunnable r2) {
if (r1 instanceof ResolveTask) {
if (r2 instanceof ResolveTask) {
final ResolveTask rt1 = (ResolveTask) r1;
final ResolveTask rt2 = (ResolveTask) r2;
final ComputationTargetReference ctr1 = rt1.getValueRequirement().getTargetReference();
final ComputationTargetReference ctr2 = rt2.getValueRequirement().getTargetReference();
final Integer p1 = s_priority.get(ctr1.getType());
final Integer p2 = s_priority.get(ctr2.getType());
if (p1.intValue() < p2.intValue()) {
return 1;
} else if (p1.intValue() > p2.intValue()) {
return -1;
} else {
if (ctr1 instanceof ComputationTargetSpecification) {
if (ctr2 instanceof ComputationTargetSpecification) {
return ObjectUtils.compare(ctr2.getSpecification().getUniqueId(), ctr1.getSpecification().getUniqueId());
} else {
// Do requirement -> specification resolution (r2) first
return -1;
}
} else {
if (ctr2 instanceof ComputationTargetRequirement) {
return ctr2.getRequirement().getIdentifiers().compareTo(ctr1.getRequirement().getIdentifiers());
} else {
// Do requirement -> specification resolution (r1) first
return 1;
}
}