Skip to content

Commit

Permalink
Fix existingOrBuild.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpwright committed Dec 5, 2023
1 parent ee0fa06 commit 0e3add2
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,10 @@ public static <T extends UpdateGraph> T buildOrThrow(final String name, final Su
* @return the UpdateGraph
*/
public static <T extends UpdateGraph> T existingOrBuild(final String name, Supplier<T> construct) {
return INSTANCES.putIfAbsent(name, construct.get()).cast();
return INSTANCES.putIfAbsent(name, (nameToInsert) -> {
final T newGraph = construct.get();
Assert.equals(newGraph.getName(), "newGraph.getName()", nameToInsert, "name");
return newGraph;
}).cast();
}
}

0 comments on commit 0e3add2

Please sign in to comment.