Skip to content

Commit dc118d7

Browse files
committed
📢 Created DataStorage.save()!
1 parent da4c047 commit dc118d7

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

‎.idea/workspace.xml

+18-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/omegaui/io/storage/DataStorage.java

+11-6
Original file line numberDiff line numberDiff line change
@@ -92,34 +92,39 @@ private void load(){
9292
public void reload(){
9393
load();
9494
}
95+
96+
private void save() {
97+
FileUtils.write(storeFile, json.toString(4));
98+
}
9599
public void put(String key, Object value){
96100
if(value instanceof Collection<?> collection)
97101
json.put(key, collection);
98102
else if(value instanceof Map<?,?> map)
99103
json.put(key, map);
100104
else
101105
json.put(key, value);
102-
FileUtils.write(storeFile, json.toString(4));
106+
save();
103107
}
108+
104109
public void put(String key, int value){
105110
json.put(key, value);
106-
FileUtils.write(storeFile, json.toString(4));
111+
save();
107112
}
108113
public void put(String key, long value){
109114
json.put(key, value);
110-
FileUtils.write(storeFile, json.toString(4));
115+
save();
111116
}
112117
public void put(String key, double value){
113118
json.put(key, value);
114-
FileUtils.write(storeFile, json.toString(4));
119+
save();
115120
}
116121
public void put(String key, float value){
117122
json.put(key, value);
118-
FileUtils.write(storeFile, json.toString(4));
123+
save();
119124
}
120125
public void put(String key, boolean value){
121126
json.put(key, value);
122-
FileUtils.write(storeFile, json.toString(4));
127+
save();
123128
}
124129
public Object get(String key){
125130
return json.get(key);

0 commit comments

Comments
 (0)