Skip to content

Commit

Permalink
added null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
leventeBajczi committed Nov 10, 2023
1 parent ad81430 commit 9743b48
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public static boolean equals(final ArgNode<? extends State, ? extends Action> n1
return true;
}

// if one is null, the two nodes are not equal
if (n1 == null || n2 == null) {
return false;
}

// if wrapped state is not same, nodes are not equal
if (!n1.getState().equals(n2.getState())) {
return false;
Expand All @@ -77,6 +82,12 @@ public static boolean equals(final ArgEdge<? extends State, ? extends Action> e1
return true;
}

// if one is null, the two edges are not equal
if (e1 == null || e2 == null) {
return false;
}


// if wrapped action is not same, edges are not equal
if (!e1.getAction().equals(e2.getAction())) {
return false;
Expand All @@ -98,6 +109,11 @@ public static boolean equals(final ARG<? extends State, ? extends Action> a1,
return true;
}

// if one is null, the two args are not equal
if (a1 == null || a2 == null) {
return false;
}

Set<ArgNode<? extends State, ? extends Action>> leaves1 = a1.getNodes().filter(ArgNode::isLeaf).collect(Collectors.toUnmodifiableSet());
Set<ArgNode<? extends State, ? extends Action>> leaves2 = a2.getNodes().filter(ArgNode::isLeaf).collect(Collectors.toUnmodifiableSet());

Expand Down

0 comments on commit 9743b48

Please sign in to comment.