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

Method save

src/main/java/field/graphics/StateTracker.java:69–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

67 }
68
69 public Util.ExceptionlessAutoClosable save() {
70
71 try {
72 if (GraphicsContext.currentGraphicsContext == null) throw new IllegalStateException(" save() only valid inside draw method ");
73 for (Field f : this.getClass()
74 .getDeclaredFields()) {
75 if (f.getType()
76 .isAssignableFrom(State.class)) {
77 try {
78 State s = (State) f.get(this);
79 allStates.put(f.getName(), s);
80 } catch (Exception e) {
81 e.printStackTrace();
82 }
83 }
84 }
85
86 List<AutoCloseable> r = new ArrayList<>();
87 for (State s : allStates.values()) {
88
89 r.add(s.save());
90 GraphicsContext.checkError(() -> "" + s);
91 }
92
93 return () -> {
94
95 r.forEach(x -> {
96 try {
97 x.close();
98 } catch (Exception e) {
99 e.printStackTrace();
100 }
101 });
102 };
103 } finally {
104// GraphicsContext.checkError();
105 }
106 }
107
108 /**
109 * dumps the current state to a string

Callers 2

drawMethod · 0.45
BaseSceneMethod · 0.45

Calls 9

saveMethod · 0.95
checkErrorMethod · 0.95
getTypeMethod · 0.80
getMethod · 0.65
closeMethod · 0.65
putMethod · 0.45
getNameMethod · 0.45
addMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected