MCPcopy Create free account
hub / github.com/agateau/pixelwheels / save

Method save

core/src/com/agateau/utils/Introspector.java:120–146  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

118 }
119
120 public void save() {
121 XmlWriter writer = new XmlWriter(mFileHandle.writer(false));
122 try {
123 XmlWriter root = writer.element("object");
124 for (Field field : mClass.getDeclaredFields()) {
125 if (!Modifier.isPublic(field.getModifiers())) {
126 continue;
127 }
128 if (Modifier.isStatic(field.getModifiers())) {
129 continue;
130 }
131 Object value = field.get(mObject);
132 if (value.equals(field.get(mReference))) {
133 continue;
134 }
135 root.element("key")
136 .attribute("name", field.getName())
137 .attribute("type", field.getType().toString())
138 .text(value.toString())
139 .pop();
140 }
141 root.pop();
142 writer.close();
143 } catch (IOException | IllegalAccessException e) {
144 e.printStackTrace();
145 }
146 }
147
148 public <T> T get(String key) {
149 return getFrom(mObject, key);

Callers 1

testRoundTripMethod · 0.95

Calls 5

popMethod · 0.80
getNameMethod · 0.65
getMethod · 0.45
equalsMethod · 0.45
toStringMethod · 0.45

Tested by 1

testRoundTripMethod · 0.76