Replace chain of ifs with switch
Sometimes if statements are chained and form a series of == comparisons
against constants. Such situation is more readable if written using
switch statement.
Change-Id: I2385da2fe081b971e530afeb98f6e68a0c588d89
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourceMappingPropertyTester.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourceMappingPropertyTester.java
index 52cdbfd..7e58b34 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourceMappingPropertyTester.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourceMappingPropertyTester.java
@@ -37,15 +37,19 @@
return false;
String propertyName;
String expectedVal;
- if (args.length == 0) {
- propertyName = toString(expectedValue);
- expectedVal = null;//any value will do
- } else if (args.length == 1) {
- propertyName = toString(args[0]);
- expectedVal = null;//any value will do
- } else {
- propertyName = toString(args[0]);
- expectedVal = toString(args[1]);
+ switch (args.length) {
+ case 0:
+ propertyName = toString(expectedValue);
+ expectedVal = null;//any value will do
+ break;
+ case 1:
+ propertyName = toString(args[0]);
+ expectedVal = null;//any value will do
+ break;
+ default:
+ propertyName = toString(args[0]);
+ expectedVal = toString(args[1]);
+ break;
}
QualifiedName key = toQualifedName(propertyName);
boolean found = false;
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourcePropertyTester.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourcePropertyTester.java
index 0703be0..f528503 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourcePropertyTester.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/propertytester/ResourcePropertyTester.java
@@ -155,15 +155,19 @@
return false;
String propertyName;
String expectedVal;
- if (args.length == 0) {
- propertyName = toString(expectedValue);
- expectedVal = null;
- } else if (args.length == 1) {
- propertyName = toString(args[0]);
- expectedVal = null;
- } else {
- propertyName = toString(args[0]);
- expectedVal = toString(args[1]);
+ switch (args.length) {
+ case 0:
+ propertyName = toString(expectedValue);
+ expectedVal = null;
+ break;
+ case 1:
+ propertyName = toString(args[0]);
+ expectedVal = null;
+ break;
+ default:
+ propertyName = toString(args[0]);
+ expectedVal = toString(args[1]);
+ break;
}
try {
QualifiedName key = toQualifedName(propertyName);