Uses 911K of libraries. Click here for Pure Java version (2761L/14K).
1 | !7 |
2 | |
3 | cmodule TransientObjectHolder > DynPrintLog { |
4 | switchable bool cleanUpObject = true; |
5 | transient O object; |
6 | transient bool reloading; |
7 | |
8 | void cleanMeUp { |
9 | if (cleanUpObject && !reloading) { |
10 | print("Cleaning up held object"); |
11 | cleanUp(object); |
12 | } |
13 | } |
14 | |
15 | // API |
16 | |
17 | O get() { |
18 | ret object; |
19 | } |
20 | |
21 | void set(O object) { |
22 | setField(+object); |
23 | printInfo(); |
24 | } |
25 | |
26 | void printInfo { |
27 | if (object == null) ret /*with print("No object")*/; |
28 | print("Have object of type: " + _getClass(object)); |
29 | print("Get it out with: dm_obj(" + dm_moduleID() + ")"); |
30 | } |
31 | |
32 | void clear() { |
33 | set(null); |
34 | } |
35 | |
36 | O _getReloadData() { |
37 | set reloading; |
38 | //print("_getReloadData: " + object; |
39 | ret object; |
40 | } |
41 | |
42 | void _setReloadData(O o) { |
43 | //print("_setReloadData: " + o); |
44 | set(o); |
45 | } |
46 | |
47 | start { |
48 | printInfo(); |
49 | } |
50 | |
51 | // API |
52 | |
53 | void dontCleanUp { |
54 | setField(cleanUpObject := false); |
55 | } |
56 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027453 |
Snippet name: | Transient Object Holder [holds a single transient Java object] |
Eternal ID of this version: | #1027453/17 |
Text MD5: | 39b45e6f13707d5d6e4d05a381e0028a |
Transpilation MD5: | 659d5ffda158ece4d78185a6a9bdd571 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-08-07 01:58:28 |
Source code size: | 989 bytes / 56 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 315 / 873 |
Version history: | 16 change(s) |
Referenced in: | [show references] |