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

Method asMap_get

src/main/java/fieldbox/boxes/Box.java:960–981  ·  view source on GitHub ↗
(String p)

Source from the content-addressed store, hash-verified

958 if (calling == null) throw new Error();
959 return calling.apply(this, a);
960 }
961
962 @Override
963 public Object asMap_get(String p) {
964
965 Optional<Box> q = startFrom.breadthFirst(startFrom.upwards())
966 .flatMap(x -> x.children()
967 .stream()
968 .filter(bx -> clazz.isInstance(bx) && bx.properties.getOr(Box.name, () -> "")
969 .equals(namePrefix + ":" + p)))
970 .findFirst();
971
972
973 if (q.isPresent()) return q.get();
974
975 Box b = autoconstructor.apply(startFrom);
976 b.properties.put(Box.name, namePrefix + ":" + p);
977 if (!clazz.isInstance(b))
978 throw new IllegalArgumentException(" autoconstructor didn't return an object of the correct class <" + b.getClass() + "> <" + clazz + ">");
979
980 startFrom.connect(b);
981
982 return b;
983 }
984

Callers

nothing calls this directly

Calls 11

breadthFirstMethod · 0.80
upwardsMethod · 0.80
childrenMethod · 0.80
getOrMethod · 0.80
isPresentMethod · 0.80
getMethod · 0.65
applyMethod · 0.65
streamMethod · 0.45
equalsMethod · 0.45
putMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected