consistent ordering of hardware

This commit is contained in:
Adrian Cole 2012-06-19 18:01:38 -06:00
parent edf99657c0
commit 09d5e8add4
2 changed files with 4 additions and 4 deletions

View File

@ -19,7 +19,7 @@
package org.jclouds.compute.domain.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.compute.util.ComputeServiceUtils.getCoresAndSpeed;
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
import static org.jclouds.compute.util.ComputeServiceUtils.getSpace;
import java.net.URI;
@ -104,9 +104,8 @@ public class HardwareImpl extends ComputeMetadataImpl implements Hardware {
public int compareTo(ResourceMetadata<ComputeType> that) {
if (that instanceof Hardware) {
Hardware thatHardware = Hardware.class.cast(that);
return ComparisonChain.start().compare(getCoresAndSpeed(this), getCoresAndSpeed(thatHardware)).compare(
this.getRam(), thatHardware.getRam()).compare(getSpace(this), getSpace(thatHardware)).compare(
getHypervisor(), thatHardware.getHypervisor()).result();
return ComparisonChain.start().compare(getCores(this), getCores(thatHardware)).compare(this.getRam(), thatHardware.getRam())
.compare(getSpace(this), getSpace(thatHardware)).result();
} else {
return super.compareTo(that);
}

View File

@ -437,6 +437,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
predicates.add(hypervisorPredicate);
predicates.add(hardwareCoresPredicate);
predicates.add(hardwareRamPredicate);
predicates.add(hardwareDiskPredicate);
// looks verbose, but explicit <Hardware> type needed for this to compile
// properly