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/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java b/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java
index 2eb1d5e..2b3121d 100644
--- a/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java
+++ b/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java
@@ -25,6 +25,7 @@
import org.onlab.packet.Ethernet;
import org.onlab.packet.ICMP6;
import org.onlab.packet.IPv6;
+import org.onlab.util.Tools;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
@@ -40,7 +41,6 @@
import java.util.Dictionary;
-import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onlab.packet.Ethernet.TYPE_ARP;
import static org.onlab.packet.Ethernet.TYPE_IPV6;
import static org.onlab.packet.ICMP6.NEIGHBOR_ADVERTISEMENT;
@@ -173,7 +173,7 @@
Dictionary<?, ?> properties = context.getProperties();
Boolean flag;
- flag = isPropertyEnabled(properties, "ipv6NeighborDiscovery");
+ flag = Tools.isPropertyEnabled(properties, "ipv6NeighborDiscovery");
if (flag == null) {
log.info("IPv6 Neighbor Discovery is not configured, " +
"using current value of {}", ipv6NeighborDiscovery);
@@ -185,26 +185,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;
- }
-
- /**
* Packet processor responsible for forwarding packets along their paths.
*/
private class ProxyArpProcessor implements PacketProcessor {