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

Class GTable2

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

Source from the content-addressed store, hash-verified

13import static Zeze.Util.Json.ensureNotNull;
14
15@SuppressWarnings("unchecked")
16public class GTable2<R, C, V extends Bean, VReadOnly> extends StandardTable<R, C, V> {
17 public static final class Factory<R, C, V extends Bean, VReadOnly> implements Supplier<Map<C, V>> {
18 private final @NotNull Meta2<R, BeanMap2<C, V, VReadOnly>> pmapMeta;
19 private final @NotNull Meta2<C, V> bmapMeta;
20 private Json.FieldMeta fm1, fm2;
21
22 Factory(@NotNull Meta2<R, BeanMap2<C, V, VReadOnly>> pmapMeta, @NotNull Meta2<C, V> bmapMeta) {
23 this.pmapMeta = pmapMeta;
24 this.bmapMeta = bmapMeta;
25 }
26
27 public @NotNull Meta2<R, BeanMap2<C, V, VReadOnly>> 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 BeanMap2<>(bmapMeta);
38 }
39 }
40
41 static {
42 var json = Json.instance;
43
44 json.getClassMeta(GTable2.class).setParser((reader, classMeta, fieldMeta, obj, parent) -> {
45 if (obj == null || fieldMeta == null)
46 return null; // 不支持GTable2新构造和非字段的GTable2对象
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 = GTable2.class.getDeclaredField("pMap2");
53 var valueClass = (Class<?>)ensureNotNull(fieldMeta.paramTypes[2]);
54 factory.fm1 = fm1 = new Json.FieldMeta(0x3c, 0, "PMap2", BeanMap2.class, factory::get,
55 Json.ClassMeta.getKeyReader((Class<?>)fieldMeta.paramTypes[0]), dummyField);
56 factory.fm2 = fm2 = new Json.FieldMeta(0x3c, 0, "BeanMap2", valueClass,
57 Json.ClassMeta.getDefCtor(valueClass),
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 //noinspection rawtypes
65 var map = (BeanMap2)ensureNotNull(fm1.ctor).create();
66 reader.parseMap0(map, classMeta, fm2);
67 obj.pMap2.put(k, map);
68 }
69 reader.pos(reader.pos() + 1);
70 return obj;
71 });
72 json.getClassMeta(GTable2.class).setWriter((writer, classMeta, obj) ->

Callers

nothing calls this directly

Calls 15

setParserMethod · 0.80
getClassMetaMethod · 0.80
getDeclaredFieldMethod · 0.80
ensureNotNullMethod · 0.80
getKeyReaderMethod · 0.80
getDefCtorMethod · 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