use of com.google.common.collect.ComparisonChain in project kylo by Teradata.
the class JpaServiceLevelAssessment method compareTo.
@Override
public int compareTo(ServiceLevelAssessment sla) {
ComparisonChain chain = ComparisonChain.start().compare(this.getResult(), sla.getResult()).compare(this.getAgreement().getName(), sla.getAgreement().getName());
if (chain.result() != 0) {
return chain.result();
}
List<ObligationAssessment> list1 = new ArrayList<>(this.getObligationAssessments());
List<ObligationAssessment> list2 = new ArrayList<>(sla.getObligationAssessments());
chain = chain.compare(list1.size(), list2.size());
Collections.sort(list1);
Collections.sort(list2);
for (int idx = 0; idx < list1.size(); idx++) {
chain = chain.compare(list1.get(idx), list2.get(idx));
}
return chain.result();
}
use of com.google.common.collect.ComparisonChain in project kylo by Teradata.
the class SimpleServiceLevelAssessment method compareTo.
@Override
public int compareTo(ServiceLevelAssessment sla) {
ComparisonChain chain = ComparisonChain.start().compare(this.getResult(), sla.getResult()).compare(this.getAgreement().getName(), sla.getAgreement().getName());
if (chain.result() != 0) {
return chain.result();
}
List<ObligationAssessment> list1 = new ArrayList<>(this.getObligationAssessments());
List<ObligationAssessment> list2 = new ArrayList<>(sla.getObligationAssessments());
chain = chain.compare(list1.size(), list2.size());
Collections.sort(list1);
Collections.sort(list2);
for (int idx = 0; idx < list1.size(); idx++) {
chain = chain.compare(list1.get(idx), list2.get(idx));
}
return chain.result();
}
use of com.google.common.collect.ComparisonChain in project buck by facebook.
the class RDotTxtEntry method compareTo.
/**
* A collection of Resources should be sorted such that Resources of the same type should be
* grouped together, and should be alphabetized within that group.
*/
@Override
public int compareTo(RDotTxtEntry that) {
if (this == that) {
return 0;
}
ComparisonChain comparisonChain = ComparisonChain.start().compare(this.type, that.type);
String[] thisNameParts = this.name.split("_");
String[] thatNameParts = that.name.split("_");
int index = 0;
while (index < thisNameParts.length && index < thatNameParts.length) {
comparisonChain = comparisonChain.compare(thisNameParts[index], thatNameParts[index]);
index++;
}
if (index < thisNameParts.length || index < thatNameParts.length) {
comparisonChain = comparisonChain.compare(thisNameParts.length, thatNameParts.length);
}
return comparisonChain.result();
}
Aggregations