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

Method thread

src/main/java/fieldbox/boxes/Callbacks.java:131–164  ·  view source on GitHub ↗
(Box from, T initial, Dict.Prop<IdempotencyMap<Box.BiFunctionOfBoxAnd<T, T>>> prop)

Source from the content-addressed store, hash-verified

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

Callers 5

frameChangeMethod · 0.95
nameChangeMethod · 0.95
executeTextFragmentMethod · 0.95
doSomethingMethod · 0.80

Calls 6

upwardsMethod · 0.80
putAllMethod · 0.80
tryToReportToMethod · 0.80
applyMethod · 0.65
streamMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected