This is an automated email from the ASF dual-hosted git repository.
kinow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git
The following commit(s) were added to refs/heads/master by this push:
new ce72c9a Replace if statements with switch statements.The result is
shorter and clearer.
ce72c9a is described below
commit ce72c9aac3eb0f2212bde81ef88694dc7557c267
Author: Arturo Bernal <[email protected]>
AuthorDate: Thu Feb 3 21:56:51 2022 +0100
Replace if statements with switch statements.The result is shorter and
clearer.
---
.../commons/imaging/formats/pnm/PamFileInfo.java | 23 ++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git
a/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java
b/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java
index 7912e9b..05f4ec4 100644
--- a/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java
+++ b/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java
@@ -53,14 +53,21 @@ class PamFileInfo extends FileInfo {
}
hasAlpha = tupleType.endsWith("_ALPHA");
- if ("BLACKANDWHITE".equals(tupleType) ||
"BLACKANDWHITE_ALPHA".equals(tupleType)) {
- tupleReader = new GrayscaleTupleReader(ImageInfo.ColorType.BW);
- } else if ("GRAYSCALE".equals(tupleType) ||
"GRAYSCALE_ALPHA".equals(tupleType)) {
- tupleReader = new
GrayscaleTupleReader(ImageInfo.ColorType.GRAYSCALE);
- } else if ("RGB".equals(tupleType) || "RGB_ALPHA".equals(tupleType)) {
- tupleReader = new ColorTupleReader();
- } else {
- throw new ImageReadException("Unknown PAM tupletype '" + tupleType
+ "'");
+ switch (tupleType) {
+ case "BLACKANDWHITE":
+ case "BLACKANDWHITE_ALPHA":
+ tupleReader = new GrayscaleTupleReader(ImageInfo.ColorType.BW);
+ break;
+ case "GRAYSCALE":
+ case "GRAYSCALE_ALPHA":
+ tupleReader = new
GrayscaleTupleReader(ImageInfo.ColorType.GRAYSCALE);
+ break;
+ case "RGB":
+ case "RGB_ALPHA":
+ tupleReader = new ColorTupleReader();
+ break;
+ default:
+ throw new ImageReadException("Unknown PAM tupletype '" +
tupleType + "'");
}
}