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)

static boolean isInstanceX(Class type, Object arg) {
  if (type == boolean.class) return arg instanceof Boolean;
  if (type == int.class) return arg instanceof Integer;
  if (type == long.class) return arg instanceof Long;
  if (type == float.class) return arg instanceof Float;
  if (type == short.class) return arg instanceof Short;
  if (type == char.class) return arg instanceof Character;
  if (type == byte.class) return arg instanceof Byte;
  if (type == double.class) return arg instanceof Double;
  return type.isInstance(arg);
}

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: 665 / 9659
Version history: 2 change(s)
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1005287 - isInstance (Class, object)
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1017021 - primitiveToBoxedType
#1021889 - isPrimitiveInstance
#3000382 - Answer for ferdie (>> t = 1, f = 0)