Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

17
LINES

< > BotCompany Repo | #1031559 // setDynTransient - set a real or dynamic field and make it transient (through persistenceInfo)

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3063L/18K).

1  
svoid setDynTransient(O o, S field, O value) ctex {
2  
  if (o == null || field == null) ret;
3  
  Field f = fieldObject(o, field);
4  
  if (f != null) {
5  
    f.set(o, value);
6  
    if (isTransient(f))
7  
      ret;
8  
    else if (!o instanceof DynamicObject)
9  
      fail("Can't make field transient: " + f);
10  
  }
11  
  
12  
  if (o cast DynamicObject) {
13  
    dynamicObject_setRawFieldValue(o, field, value);
14  
    addToPersistenceInfo(o, field, false);
15  
  } else
16  
    fail("Field not found in " + className(o) + ": " + field);
17  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031559
Snippet name: setDynTransient - set a real or dynamic field and make it transient (through persistenceInfo)
Eternal ID of this version: #1031559/5
Text MD5: 7dd25bf9be9c9975c1090bba6db6a1db
Transpilation MD5: 678ee6fa767c2069b568fc842d7354bd
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-22 00:41:31
Source code size: 513 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 174 / 246
Version history: 4 change(s)
Referenced in: [show references]