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

13
LINES

< > BotCompany Repo | #1035539 // preciseGetOrCallMethod_sentinel

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

Libraryless. Click here for Pure Java version (9290L/51K).

1  
sO preciseGetOrCallMethod_sentinel(O object, S name, O sentinel) {
2  
  if (object == null) null;
3  
  
4  
  // could optimize more for sure
5  
  if (canCallWithVarargs(object, name))
6  
    ret call(object, name);
7  
    
8  
  Field f = getField(object, name);
9  
  if (f != null)
10  
    ret fieldGet(f, object);
11  
  
12  
  ret sentinel;
13  
}

Author comment

Began life as a copy of #1035088

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035539
Snippet name: preciseGetOrCallMethod_sentinel
Eternal ID of this version: #1035539/3
Text MD5: 86ce0f4e5f47f538865a33e2303d865f
Transpilation MD5: f96a241060ed51f1d77232642405a1ef
Author: stefan
Category: javax / reflection
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-10 23:55:20
Source code size: 319 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 64 / 96
Version history: 2 change(s)
Referenced in: [show references]