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

16
LINES

< > BotCompany Repo | #1007854 // methodApplicabilityScore

JavaX fragment (include)

// return Int.MAX_VALUE if not applicable
// Lower score is better
static int methodApplicabilityScore(Method m, O[] args) {
   Class<?>[] types = m.getParameterTypes();
   if (types.length != args.length) ret Int.MAX_VALUE;
   int score = 0;
   for (int i = 0; i < types.length; i++) {
     O a = args[i];
     Class c = types[i];
     if (a == null) ++score;
     else if (c == a.getClass()) {} // perfect match
     else if (isInstanceX(c, a)) ++score;
     else ret Int.MAX_VALUE;
  }
  ret score;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1007854
Snippet name: methodApplicabilityScore
Eternal ID of this version: #1007854/2
Text MD5: 9f6bab1fdd18b836727dffebc1bf5853
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-11 23:11:51
Source code size: 518 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 383 / 416
Version history: 1 change(s)
Referenced in: [show references]