Closed arolfes closed 9 years ago
for given example the output would be:
public class SampleBean implements Comparable<SampleBean> {
private int testInt;
private String testString;
private Object testObject;
@Override
public int compareTo(SampleBean that) {
return ComparisonChain.start().compare(this.testInt, that.testInt)
.compare(this.testString, that.testString)
// XXX field 'testObject' java.lang.Object is not comparable
//.compare(this.testObject, that.testObject)
.result();
}
}
a more complex example
public class CompareTest implements Comparable<CompareTest> {
private String[] arraySample1;
private ClassWithComparable compEnabled;
private ClassWithoutComparable compDisabled;
private int intValue3;
private SampleEnum enumValue1;
private String simpleString1;
private InterfaceWithComparable iFaceWithComp;
private InterfaceWithoutComparable iFaceWithoutComp;
private ClassExtendsSomeComparable compEnabled2;
private ClassExtendSomeNonComparable compDisabled2;
private AbstractClassWithComparable compEnabled3;
private AbstractClassWithoutComparable compDisabled3;
@Override
public int compareTo(CompareTest that) {
return ComparisonChain.start()
// XXX field 'arraySample1' is an Array! and they are not comparable by default
//.compare(this.arraySample1, that.arraySample1)
.compare(this.compEnabled, that.compEnabled)
// XXX field 'compDisabled' does not implements java.lang.Comparable
//.compare(this.compDisabled, that.compDisabled)
.compare(this.intValue3, that.intValue3)
.compare(this.enumValue1, that.enumValue1)
.compare(this.simpleString1, that.simpleString1)
.compare(this.iFaceWithComp, that.iFaceWithComp)
// XXX field 'iFaceWithoutComp' does not implements java.lang.Comparable
//.compare(this.iFaceWithoutComp, that.iFaceWithoutComp)
.compare(this.compEnabled2, that.compEnabled2)
// XXX field 'compDisabled2' does not implements java.lang.Comparable
//.compare(this.compDisabled2, that.compDisabled2)
.compare(this.compEnabled3, that.compEnabled3)
// XXX field 'compDisabled3' does not implements java.lang.Comparable
//.compare(this.compDisabled3, that.compDisabled3)
.result();
}
}
fixed with latest snapshot 1.4.0.201507091317 https://GuavaEclipseHelperTeam.github.io/updateSite/snapshots/LATEST
i will prepare a full release
2ebd7cf7fd3d67a2adcc5dfb6a3a33df54c08b4b
if you a variable which does not implement the comparable interface generated code does not compile.
Example