aboutsummaryrefslogtreecommitdiffstats
path: root/poi
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2022-07-10 10:24:34 +0000
committerPJ Fanning <fanningpj@apache.org>2022-07-10 10:24:34 +0000
commit4cda0c91fd6c67aebdfa28febc296f271dec215d (patch)
treec464c3de297e1acbe678852d5e2f0e52b8123fc0 /poi
parent6602122926db0bc9623811675b8fed2902b41ce4 (diff)
downloadpoi-4cda0c91fd6c67aebdfa28febc296f271dec215d.tar.gz
poi-4cda0c91fd6c67aebdfa28febc296f271dec215d.zip
throw exception if wrong Color class is used
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902623 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi')
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
index 9bb826d56a..bff242f0c4 100644
--- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
+++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
@@ -642,6 +642,7 @@ public final class HSSFCellStyle implements CellStyle, Duplicatable {
* Set the background fill color represented as a {@link org.apache.poi.ss.usermodel.Color} value.
* <br>
* @param color the color to use
+ * @throws IllegalArgumentException if you provide a <code>Color</code> instance that is not a {@link HSSFColor}
* @since POI 5.2.3
*/
@Override
@@ -650,6 +651,8 @@ public final class HSSFCellStyle implements CellStyle, Duplicatable {
if (color instanceof HSSFColor) {
short index2 = ((HSSFColor)color).getIndex2();
if (index2 != -1) setFillBackgroundColor(index2);
+ } else {
+ throw new IllegalArgumentException("HSSFCellStyle only accepts HSSFColor instances");
}
}
@@ -698,6 +701,7 @@ public final class HSSFCellStyle implements CellStyle, Duplicatable {
* Set the foreground fill color represented as a {@link org.apache.poi.ss.usermodel.Color} value.
* <br>
* @param color the color to use
+ * @throws IllegalArgumentException if you provide a <code>Color</code> instance that is not a {@link HSSFColor}
* @since POI 5.2.3
*/
@Override
@@ -706,6 +710,8 @@ public final class HSSFCellStyle implements CellStyle, Duplicatable {
if (color instanceof HSSFColor) {
short index2 = ((HSSFColor)color).getIndex2();
if (index2 != -1) setFillForegroundColor(index2);
+ } else {
+ throw new IllegalArgumentException("HSSFCellStyle only accepts HSSFColor instances");
}
}