X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcore%2FNodeConnector.java;h=50ccf69b4090ad220aebb5b97b35559f978efd56;hb=51e9be2b3aac6ea33bf21e5a3a978325d24e9e0e;hp=85a6c22c568cd97894c420c2850eeb848a6a1b14;hpb=f5ae77b71afeee5667bf2a8ad9d0753025ee1947;p=controller.git diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java index 85a6c22c56..50ccf69b40 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java @@ -19,17 +19,18 @@ package org.opendaylight.controller.sal.core; import java.io.Serializable; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import org.apache.commons.lang3.tuple.ImmutablePair; import org.opendaylight.controller.sal.utils.INodeConnectorFactory; -import org.opendaylight.controller.sal.utils.INodeFactory; import org.opendaylight.controller.sal.utils.ServiceHelper; /** @@ -408,28 +409,37 @@ public class NodeConnector implements Serializable { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } NodeConnector other = (NodeConnector) obj; if (nodeConnectorID == null) { - if (other.nodeConnectorID != null) + if (other.nodeConnectorID != null) { return false; - } else if (!nodeConnectorID.equals(other.nodeConnectorID)) + } + } else if (!nodeConnectorID.equals(other.nodeConnectorID)) { return false; + } if (nodeConnectorNode == null) { - if (other.nodeConnectorNode != null) + if (other.nodeConnectorNode != null) { return false; - } else if (!nodeConnectorNode.equals(other.nodeConnectorNode)) + } + } else if (!nodeConnectorNode.equals(other.nodeConnectorNode)) { return false; + } if (nodeConnectorType == null) { - if (other.nodeConnectorType != null) + if (other.nodeConnectorType != null) { return false; - } else if (!nodeConnectorType.equals(other.nodeConnectorType)) + } + } else if (!nodeConnectorType.equals(other.nodeConnectorType)) { return false; + } return true; } @@ -484,6 +494,27 @@ public class NodeConnector implements Serializable { return fromStringNoNode(parts[0], n); } + /** + * return a set of NodeConnector from a collection of string + * + * @param stringCollection Collection of String object to be parsed as a NodeConnector + * + * @return the Set of unique NodeConnector objects if parse is successful, empty Set otherwise + */ + public static Set fromString(Collection stringCollection) { + Set set = new HashSet(); + if (stringCollection != null) { + + for (String str : stringCollection) { + NodeConnector nodeConnector = NodeConnector.fromString(str); + if (nodeConnector != null) { + set.add(nodeConnector); + } + } + } + return set; + } + /** * return a NodeConnector from a string not containing explicitly * the Node portion which has to be supplied as parameter @@ -609,8 +640,9 @@ public class NodeConnector implements Serializable { //The protocol plugin being used depends on typeStr. INodeConnectorFactory f = (INodeConnectorFactory) ServiceHelper .getGlobalInstance(INodeConnectorFactory.class, new NodeConnector(), "(protocolName="+typeStr+")"); - if(f==null) + if(f==null) { return null; + } return f.fromStringNoNode(typeStr, IDStr, n); } }