tidy up
This commit is contained in:
parent
f1cf6e13aa
commit
1fb18290ca
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user