]> source.dussan.org Git - poi.git/commitdiff
Change logic to avoid a 1.6 compiler bug that doesn't properly handle generics. ...
authorGreg Woolsey <gwoolsey@apache.org>
Tue, 14 Feb 2017 22:00:05 +0000 (22:00 +0000)
committerGreg Woolsey <gwoolsey@apache.org>
Tue, 14 Feb 2017 22:00:05 +0000 (22:00 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1783035 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java

index 9ccb5bd5eaac33bda240c547572b630a252e250a..b01a7fbf8549514580f7dbdd9fcc073302f8588e 100644 (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;
             }