-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Class_TableUtil.xpp
164 lines (131 loc) · 4.17 KB
/
Class_TableUtil.xpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//
// https://github.com/mazzy-ax/SysUtil
//
// Класс обслуживает значения с типом TableId
// Util-класс реализует только статические методы.
// не содержит внутри никаких значений.
// не имеет смысла создавать экземпляр этого класса.
//
// @see DictTableUtil
//
abstract class TableUtil
{
public static TableId commonTableId()
{
// Common rec;
//
// return rec.TableId;
return tablenum(Common);
// return 65535;
}
// используйте new DictTable чтобы создать объект без проверки на null
public static DictTable dictTable_NonNull(TableId tableId)
{
DictTable dt = new DictTable(tableId);
;
dt = DictTableUtil::nonNull(dt);
return dt;
}
public static boolean is(TableId tableId, TableId tableOrMapId)
{
if( tableId == tableOrMapId )
return true;
if( tableOrMapId && TableUtil::isMapped(tableId, tableOrMapId) )
return true;
return false;
}
public static boolean isCommon(TableId tableId)
{
boolean ret = (tableId == tablenum(Common));
return ret;
}
static boolean isMapped(TableId tableId, TableId potentialMapId)
{
#AOT
TableName mapName;
TreeNode treeNode;
TableName tableName;
boolean ret;
if( tableId )
{
if( TableUtil::isCommon(potentialMapId) )
{
ret = true;
}
else
{
tableName = tableid2name(tableId);
mapName = tableid2name(potentialMapId);
if( tableName && mapName )
{
treeNode = TreeNode::findNode(#TableMapsPath+'\\'+mapName+'\\mappings');
ret = treeNode ? (treeNode.AOTfindChild(tableName) != null) : false;
}
}
}
return ret;
}
public static boolean isNotCommon(TableId tableId)
{
boolean ret = (tableId != tablenum(Common));
return ret;
}
public static boolean isNotSpecified(TableId tableId)
{
boolean ret = (tableId == 0 || tableId == tablenum(Common));
return ret;
}
public static boolean isSpecified(TableId tableId)
{
boolean ret = (tableId && tableId != tablenum(Common));
return ret;
}
public static Common makeRecord(TableId tableId = 0)
{
Common record;
DictTable dt;
if( tableId )
{
dt = new DictTable(tableId);
if( dt )
{
record = dt.makeRecord();
}
}
return record;
}
public static Common makeRecordTmp(TableId tableId = 0)
{
Common record = TableUtil::makeRecord(tableId);
;
record.setTmp();
return record;
}
// используйте new SysDictTable чтобы создать объект без проверки на Null
public static SysDictTable sysDictTable_NonNull(TableId tableId)
{
SysDictTable dt = new SysDictTable(tableId);
;
if( !dt )
{
dt = new SysDictTable(tablenum(Common));
}
return dt;
}
// Возвращает подходящий не nullable объект.
// Полезно в выражениях, чтобы быть уверенным, что после выполнения этого метода объект точно не null
//
// not в названиях методов прочно ассоциируется с оператором логического отрицания (!)
// Поэтому название этого метода NonNull, а не NotNull
//
// @see https://stackoverflow.com/questions/4963300/which-notnull-java-annotation-should-i-use
//
public static SysDictTable sysNonNull(SysDictTable dt)
{
if( !dt )
{
new SysDictTable(tablenum(Common));
}
return dt;
}
}