This commit is contained in:
mattbradburyr3 2023-01-29 17:13:28 +00:00
parent 716f15fe83
commit f1cf6e13aa
3 changed files with 17 additions and 18 deletions

View File

@ -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> T findAndExpectExactlyOne(Collection<T> collection, Predicate<? super T> filterFn, String exceptionMsg)
{
Collection<T> results = collection.stream().filter(filterFn).collect(Collectors.toList());
if(results.size() != 1){
throw new RuntimeException(exceptionMsg);
}
return results.iterator().next();
}
public static <T> T findAndExpectExactlyOne(Collection<T> collection, String exceptionMsg) {
return findAndExpectExactlyOne(collection, e -> true, exceptionMsg);
}
}
//
//public final class CorDappHelpers {
// public static <T> T findAndExpectExactlyOne(Collection<T> collection, Predicate<? super T> filterFn, String exceptionMsg)
// {
// Collection<T> results = collection.stream().filter(filterFn).collect(Collectors.toList());
// if(results.size() != 1){
// throw new RuntimeException(exceptionMsg);
// }
// return results.iterator().next();
// }
//
// public static <T> T findAndExpectExactlyOne(Collection<T> collection, String exceptionMsg) {
// return findAndExpectExactlyOne(collection, e -> true, exceptionMsg);
// }
//}

View File

@ -33,8 +33,8 @@ public class FinalizeChatSubFlow implements SubFlow<String> {
@Suspendable
public String call() {
log.info("AppendChatFlow.call() called");
log.info("otherMember = " + otherMember);
// log.info("AppendChatFlow.call() called");
// log.info("otherMember = " + otherMember);
FlowSession session = flowMessaging.initiateFlow(otherMember);
String retVal;

View File

@ -26,7 +26,6 @@ import java.time.Instant;
import java.util.List;
import java.util.stream.Collectors;
import static com.r3.developers.csdetemplate.utilities.CorDappHelpers.findAndExpectExactlyOne;
import static java.util.Objects.*;
import static java.util.stream.Collectors.toList;