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

Method fromValue

src/main/java/fieldbox/io/Raft.java:202–224  ·  view source on GitHub ↗
(Dict.Prop<T> key, Object value, Function<String, Box> alias, Predicate<Node> load)

Source from the content-addressed store, hash-verified

200 Pattern extractClass = Pattern.compile("%%(.*?)%%(.*)", Pattern.DOTALL);
201
202 private <T> T fromValue(Dict.Prop<T> key, Object value, Function<String, Box> alias, Predicate<Node> load) throws InstantiationException, IllegalAccessException, IOException, ClassNotFoundException {
203 if (value == null) return null;
204
205 if (value instanceof String) {
206 if (((String) value).startsWith("%%")) {
207 Matcher m = extractClass.matcher(((String) value));
208 m.find();
209 String className = m.group(1);
210 String content = m.group(2);
211
212 return (T) fromValue(key, className, content, alias, load);
213 }
214 }
215
216 if (value instanceof Node) {
217 // consider this a little...
218 Log.log("error.raft", () -> "cannot deserialize box reference");
219 return null;
220// return (T) _loadBox((String) ((Node) value).getProperty("uid"), alias, load);
221 }
222
223 return (T) value;
224 }
225
226
227

Callers 1

_loadBoxMethod · 0.95

Calls 4

logMethod · 0.95
deserializeMethod · 0.95
findMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected