MCPcopy Create free account
hub / github.com/e2wugui/zeze / GTable1

Class GTable1

ZezeJava/ZezeJava/src/main/java/Zeze/Transaction/GTable/GTable1.java:15–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13import static Zeze.Util.Json.ensureNotNull;
14
15@SuppressWarnings("unchecked")
16public class GTable1<R, C, V> extends StandardTable<R, C, V> {
17 public static final class Factory<R, C, V> implements Supplier<Map<C, V>> {
18 private final @NotNull Meta2<R, BeanMap1<C, V>> pmapMeta;
19 private final @NotNull Meta2<C, V> bmapMeta;
20 private Json.FieldMeta fm1, fm2;
21
22 Factory(@NotNull Meta2<R, BeanMap1<C, V>> pmapMeta, @NotNull Meta2<C, V> bmapMeta) {
23 this.pmapMeta = pmapMeta;
24 this.bmapMeta = bmapMeta;
25 }
26
27 public @NotNull Meta2<R, BeanMap1<C, V>> getPmapMeta() {
28 return pmapMeta;
29 }
30
31 public @NotNull Meta2<C, V> getBmapMeta() {
32 return bmapMeta;
33 }
34
35 @Override
36 public @NotNull Map<C, V> get() {
37 return new BeanMap1<>(bmapMeta);
38 }
39 }
40
41 static {
42 var json = Json.instance;
43
44 json.getClassMeta(GTable1.class).setParser((reader, classMeta, fieldMeta, obj, parent) -> {
45 if (obj == null || fieldMeta == null)
46 return null; // 不支持GTable1新构造和非字段的GTable1对象
47 obj.pMap2.clear();
48 var factory = (Factory<?, ?, ?>)obj.factory;
49 var fm1 = factory.fm1;
50 var fm2 = factory.fm2;
51 if (fm1 == null) {
52 var dummyField = GTable1.class.getDeclaredField("pMap2");
53 factory.fm1 = fm1 = new Json.FieldMeta(0x3c, 0, "PMap2", BeanMap1.class, factory::get,
54 Json.ClassMeta.getKeyReader((Class<?>)fieldMeta.paramTypes[0]), dummyField);
55 factory.fm2 = fm2 = new Json.FieldMeta(0x30 + Json.ClassMeta.getType((Class<?>)fieldMeta.paramTypes[2]),
56 0, "BeanMap1", Object.class,
57 Json.ClassMeta.getDefCtor((Class<?>)ensureNotNull(fieldMeta.paramTypes[2])),
58 Json.ClassMeta.getKeyReader((Class<?>)fieldMeta.paramTypes[1]), dummyField);
59 }
60 var keyParser = ensureNotNull(fm1.keyParser);
61 for (int b = reader.skipNext(); b != '}'; b = reader.skipVar('}')) {
62 var k = keyParser.parse(reader, b);
63 reader.skipColon();
64 var map = (BeanMap1<Object, Object>)ensureNotNull(fm1.ctor).create();
65 reader.parseMap0(map, classMeta, fm2);
66 obj.pMap2.put(k, map);
67 }
68 reader.pos(reader.pos() + 1);
69 return obj;
70 });
71 json.getClassMeta(GTable1.class).setWriter((writer, classMeta, obj) ->
72 writer.write(json, obj != null ? obj.pMap2 : null));

Callers

nothing calls this directly

Calls 15

setParserMethod · 0.80
getClassMetaMethod · 0.80
getDeclaredFieldMethod · 0.80
getKeyReaderMethod · 0.80
getDefCtorMethod · 0.80
ensureNotNullMethod · 0.80
skipNextMethod · 0.80
skipVarMethod · 0.80
skipColonMethod · 0.80
parseMap0Method · 0.80
posMethod · 0.80
setWriterMethod · 0.80

Tested by

no test coverage detected