Explicit null checks to avoid it trickling down into code where it's harder to tell.

This commit is contained in:
Florian Nücke 2016-06-25 14:26:28 +02:00
parent 422592d84e
commit 9a3fd0feb2

View File

@ -72,6 +72,9 @@ private class Network private(private val data: mutable.Map[String, Network.Vert
// ----------------------------------------------------------------------- // // ----------------------------------------------------------------------- //
def connect(nodeA: MutableNode, nodeB: MutableNode) = { def connect(nodeA: MutableNode, nodeB: MutableNode) = {
if (nodeA == null) throw new NullPointerException("nodeA")
if (nodeB == null) throw new NullPointerException("nodeB")
if (nodeA == nodeB) throw new IllegalArgumentException( if (nodeA == nodeB) throw new IllegalArgumentException(
"Cannot connect a node to itself.") "Cannot connect a node to itself.")