Refactor getIntegerProperty and isPropertyEnabled methods into Tools
- Add getIntegerProperty and isPropertyEnabled methods which take
default value as third parameter
- Remove all duplicated code from RefactiveForwarding, GroupManager,
FlowRuleManager, CoreManager, HostLocationProvider and ProxyArp
Change-Id: Ifc93aa813acfdd4cbac0166497d7b526b08b2090
diff --git a/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java b/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java
index d1aa771..051b2a0 100644
--- a/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java
+++ b/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java
@@ -35,6 +35,7 @@
import org.onlab.packet.ndp.NeighborSolicitation;
import org.onlab.packet.ndp.RouterAdvertisement;
import org.onlab.packet.ndp.RouterSolicitation;
+import org.onlab.util.Tools;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
@@ -69,7 +70,6 @@
import java.util.Set;
import java.util.concurrent.ExecutorService;
-import static com.google.common.base.Strings.isNullOrEmpty;
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
import static org.onlab.util.Tools.groupedThreads;
import static org.slf4j.LoggerFactory.getLogger;
@@ -228,7 +228,7 @@
Dictionary<?, ?> properties = context.getProperties();
Boolean flag;
- flag = isPropertyEnabled(properties, "hostRemovalEnabled");
+ flag = Tools.isPropertyEnabled(properties, "hostRemovalEnabled");
if (flag == null) {
log.info("Host removal on port/device down events is not configured, " +
"using current value of {}", hostRemovalEnabled);
@@ -238,7 +238,7 @@
hostRemovalEnabled ? "enabled" : "disabled");
}
- flag = isPropertyEnabled(properties, "ipv6NeighborDiscovery");
+ flag = Tools.isPropertyEnabled(properties, "ipv6NeighborDiscovery");
if (flag == null) {
log.info("Using IPv6 Neighbor Discovery is not configured, " +
"using current value of {}", ipv6NeighborDiscovery);
@@ -248,7 +248,7 @@
ipv6NeighborDiscovery ? "enabled" : "disabled");
}
- flag = isPropertyEnabled(properties, "requestInterceptsEnabled");
+ flag = Tools.isPropertyEnabled(properties, "requestInterceptsEnabled");
if (flag == null) {
log.info("Request intercepts is not configured, " +
"using current value of {}", requestInterceptsEnabled);
@@ -259,26 +259,6 @@
}
}
- /**
- * Check property name is defined and set to true.
- *
- * @param properties properties to be looked up
- * @param propertyName the name of the property to look up
- * @return value when the propertyName is defined or return null
- */
- private static Boolean isPropertyEnabled(Dictionary<?, ?> properties,
- String propertyName) {
- Boolean value = null;
- try {
- String s = (String) properties.get(propertyName);
- value = isNullOrEmpty(s) ? null : s.trim().equals("true");
- } catch (ClassCastException e) {
- // No propertyName defined.
- value = null;
- }
- return value;
- }
-
@Override
public void triggerProbe(Host host) {
log.info("Triggering probe on device {}", host);