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

Method wrap

src/main/java/field/utility/Util.java:66–83  ·  view source on GitHub ↗
(Function<T, R> a, Errors error, R def, Class convertReturn)

Source from the content-addressed store, hash-verified

64 }
65
66 public static <T, R> Function<T, R> wrap(Function<T, R> a, Errors error, R def, Class convertReturn) {
67 return x -> {
68 try {
69 Object q = a.apply(x);
70
71 if (convertReturn != null) q = Conversions.convert(q, convertReturn);
72
73
74// if (q instanceof Undefined) return null;
75
76 return (R) q;
77 } catch (Throwable t) {
78 t.printStackTrace();
79 error.add(t, a);
80 return def;
81 }
82 };
83 }
84
85 public static <T> Consumer<T> wrap(Consumer<T> a, Errors error) {
86 return x -> {

Callers 4

dispatchMethod · 0.95
drawMethod · 0.95
dispatchMethod · 0.95

Calls 4

convertMethod · 0.95
applyMethod · 0.65
acceptMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected