Change logic to avoid a 1.6 compiler bug that doesn't properly handle generics. Eclipse compiler and JDK > 1.6 work properly, even with target runtime = 1.6, so I didn't see it locally. had to compile with the same version of the JDK as the build machine to see the problem.

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1783035 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Greg Woolsey 2017-02-14 22:00:05 +00:00
parent 64f9c52a7d
commit f990d41c78
1 changed files with 6 additions and 4 deletions

View File

@ -594,16 +594,18 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
},
EQUAL {
public <C extends Comparable<C>> boolean isValid(C cellValue, C v1, C v2) {
if (cellValue instanceof String) {
return ((String) cellValue).compareToIgnoreCase((String) v1) == 0;
// need to avoid instanceof, to work around a 1.6 compiler bug
if (cellValue.getClass() == String.class) {
return cellValue.toString().compareToIgnoreCase(v1.toString()) == 0;
}
return cellValue.compareTo(v1) == 0;
}
},
NOT_EQUAL {
public <C extends Comparable<C>> boolean isValid(C cellValue, C v1, C v2) {
if (cellValue instanceof String) {
return ((String) cellValue).compareToIgnoreCase((String) v1) != 0;
// need to avoid instanceof, to work around a 1.6 compiler bug
if (cellValue.getClass() == String.class) {
return cellValue.toString().compareToIgnoreCase(v1.toString()) == 0;
}
return cellValue.compareTo(v1) != 0;
}