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

11
LINES

< > BotCompany Repo | #1000961 // isInstanceX - extended over Class.isInstance() to handle primitive types

JavaX fragment (include)

1  
static boolean isInstanceX(Class type, Object arg) {
2  
  if (type == boolean.class) return arg instanceof Boolean;
3  
  if (type == int.class) return arg instanceof Integer;
4  
  if (type == long.class) return arg instanceof Long;
5  
  if (type == float.class) return arg instanceof Float;
6  
  if (type == short.class) return arg instanceof Short;
7  
  if (type == char.class) return arg instanceof Character;
8  
  if (type == byte.class) return arg instanceof Byte;
9  
  if (type == double.class) return arg instanceof Double;
10  
  return type.isInstance(arg);
11  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1000961
Snippet name: isInstanceX - extended over Class.isInstance() to handle primitive types
Eternal ID of this version: #1000961/3
Text MD5: f486f738e6d85c927041523ab0713d1c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-27 13:00:58
Source code size: 548 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 755 / 9755
Version history: 2 change(s)
Referenced in: [show references]