1
mirror of https://github.com/CarmJos/EasyConfiguration.git synced 2026-06-04 18:48:20 +08:00

[2.1.0] 实现JSON版本的数据格式

This commit is contained in:
2022-04-22 12:57:10 +08:00
parent 42ccc23347
commit dd7a6c819f
23 changed files with 614 additions and 39 deletions
@@ -0,0 +1,39 @@
package config.model;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.TestOnly;
import java.util.HashMap;
import java.util.Map;
public class SomeModel extends AbstractModel {
int num;
public SomeModel(@NotNull String name, int num) {
super(name);
this.num = num;
}
@Override
public String toString() {
return "SomeModel{" +
"name='" + name + '\'' +
", num=" + num +
'}';
}
public @NotNull Map<String, Object> serialize() {
Map<String, Object> map = new HashMap<>();
map.put("name", name);
map.put("num", num);
return map;
}
@TestOnly
public static SomeModel deserialize(Map<String, ?> args) {
return new SomeModel((String) args.get("name"), (Integer) args.get("num"));
}
}