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

Method apply

src/main/java/field/utility/Cached.java:41–69  ·  view source on GitHub ↗
(t_check check)

Source from the content-addressed store, hash-verified

39 }
40
41 public t_value apply(t_check check) {
42 t_witness w;
43 try {
44 w = witness.apply(check);
45 }
46 catch(Throwable t)
47 {
48 System.err.println(" exception thrown by witness :"+witness+" carying on");
49 t.printStackTrace();
50 w=null;
51 invalid = true;
52 }
53
54 t_witness finalW = w;
55 if (invalid || !Util.safeEq(w, valid)) {
56 if (debug != null) {
57 Log.log("cached." + debug, ()->" cache invalid :" + invalid + " " + finalW + " " + valid + " " + Util.safeEq(finalW, valid));
58 }
59 value = compute.apply(check, value);
60 valid = w;
61
62 if (valid instanceof Mutable)
63 valid = (t_witness) ((Mutable)valid).duplicate();
64
65 invalid = false;
66 } else if (debug != null)
67 Log.log("cached." + debug,()-> " cache valid :" + invalid + " " + finalW + " " + valid + " " + Util.safeEq(finalW, valid));
68 return value;
69 }
70
71 public Cached<t_check, t_witness, t_value> debugOn(String name) {
72 this.debug = name;

Callers 2

toSupplierMethod · 0.95
relativeToMethod · 0.95

Calls 5

safeEqMethod · 0.95
logMethod · 0.95
applyMethod · 0.65
duplicateMethod · 0.65
printlnMethod · 0.45

Tested by

no test coverage detected