(Box from, T initial, Dict.Prop<IdempotencyMap<Box.BiFunctionOfBoxAnd<T, T>>> prop)
| 129 | static public String nameChange(Box from, String a) { |
| 130 | return thread(from, a, onNameChange); |
| 131 | } |
| 132 | |
| 133 | static public <T> T thread(Box from, T initial, Dict.Prop<IdempotencyMap<Box.BiFunctionOfBoxAnd<T, T>>> prop) { |
| 134 | Object[] az = {initial}; |
| 135 | |
| 136 | /* |
| 137 | from.breadthFirst(from.upwards()) |
| 138 | .map(x -> x.properties.get(prop)) |
| 139 | .filter(x -> x != null) |
| 140 | .flatMap(x -> x.values() |
| 141 | .stream()) |
| 142 | .forEach(x -> { |
| 143 | az[0] = x.apply(from, (T) az[0]); |
| 144 | }); |
| 145 | |
| 146 | */ |
| 147 | |
| 148 | // this logic lets children override parents (you can use '_._' for a guarenteed unique namespace |
| 149 | from.find(prop, from.upwards()) |
| 150 | .reduce(new IdempotencyMap<>(Box.BiFunctionOfBoxAnd.class), (a, b) -> { |
| 151 | IdempotencyMap<Box.BiFunctionOfBoxAnd<T, T>> i = new IdempotencyMap<>(Box.BiFunctionOfBoxAnd.class); |
| 152 | i.putAll(a); |
| 153 | i.putAll(b); |
| 154 | return i; |
| 155 | }) |
| 156 | .values() |
| 157 | .stream() |
| 158 | .forEachOrdered(x -> { |
| 159 | try { |
| 160 | az[0] = x.apply(from, (T) az[0]); |
| 161 | } catch (Throwable t) { |
| 162 | Errors.INSTANCE.tryToReportTo(t, "Inside call[" + prop + "]", x); |
| 163 | } |
| 164 | }); |
| 165 | return (T) az[0]; |
| 166 | } |
| 167 |
no test coverage detected