From 1fb18290ca783498e459726b031f2c0f8e35f8f5 Mon Sep 17 00:00:00 2001 From: mattbradburyr3 Date: Sun, 29 Jan 2023 17:23:49 +0000 Subject: [PATCH] tidy up --- .../utilities/CorDappHelpers.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/workflows/src/main/java/com/r3/developers/csdetemplate/utilities/CorDappHelpers.java b/workflows/src/main/java/com/r3/developers/csdetemplate/utilities/CorDappHelpers.java index b392a00..e66299c 100644 --- a/workflows/src/main/java/com/r3/developers/csdetemplate/utilities/CorDappHelpers.java +++ b/workflows/src/main/java/com/r3/developers/csdetemplate/utilities/CorDappHelpers.java @@ -6,18 +6,18 @@ import java.util.List; import java.util.concurrent.Callable; import java.util.function.Predicate; import java.util.stream.Collectors; -// -//public final class CorDappHelpers { -// public static T findAndExpectExactlyOne(Collection collection, Predicate filterFn, String exceptionMsg) -// { -// Collection results = collection.stream().filter(filterFn).collect(Collectors.toList()); -// if(results.size() != 1){ -// throw new RuntimeException(exceptionMsg); -// } -// return results.iterator().next(); -// } -// -// public static T findAndExpectExactlyOne(Collection collection, String exceptionMsg) { -// return findAndExpectExactlyOne(collection, e -> true, exceptionMsg); -// } -//} + +public final class CorDappHelpers { + public static T findAndExpectExactlyOne(Collection collection, Predicate filterFn, String exceptionMsg) + { + Collection results = collection.stream().filter(filterFn).collect(Collectors.toList()); + if(results.size() != 1){ + throw new RuntimeException(exceptionMsg); + } + return results.iterator().next(); + } + + public static T findAndExpectExactlyOne(Collection collection, String exceptionMsg) { + return findAndExpectExactlyOne(collection, e -> true, exceptionMsg); + } +}