MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / closeable

Method closeable

src/main/java/field/utility/Util.java:24–46  ·  view source on GitHub ↗

exception munging list autoclosable

(Collection<? extends AutoCloseable> c)

Source from the content-addressed store, hash-verified

22 * exception munging list autoclosable
23 */
24 static public AutoCloseable closeable(Collection<? extends AutoCloseable> c) {
25
26 for (AutoCloseable cc : c) {
27 if (cc instanceof Bracketable) ((Bracketable) cc).open();
28 }
29
30 return () -> {
31 List<Throwable> thrown = new ArrayList<>();
32 c.forEach((autoCloseable) -> {
33 try {
34 autoCloseable.close();
35 } catch (Exception e) {
36 e.printStackTrace();
37 thrown.add(e);
38 }
39 });
40 if (thrown.size() > 0) {
41 Exception e = new Exception(" exception(s) throw during close " + thrown);
42 e.initCause(thrown.get(0));
43 throw e;
44 }
45 };
46 }
47
48 /**
49 * exception munging list autoclosable

Callers 1

drawNowMethod · 0.80

Calls 7

asListMethod · 0.80
openMethod · 0.65
closeMethod · 0.65
getMethod · 0.65
forEachMethod · 0.45
addMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected