1 | // return Int.MAX_VALUE if not applicable |
2 | // Lower score is better |
3 | static int methodApplicabilityScore(Method m, O[] args) {
|
4 | Class<?>[] types = m.getParameterTypes(); |
5 | if (types.length != args.length) ret Int.MAX_VALUE; |
6 | int score = 0; |
7 | for (int i = 0; i < types.length; i++) {
|
8 | O a = args[i]; |
9 | Class c = types[i]; |
10 | if (a == null) ++score; |
11 | else if (c == a.getClass()) {} // perfect match
|
12 | else if (isInstanceX(c, a)) ++score; |
13 | else ret Int.MAX_VALUE; |
14 | } |
15 | ret score; |
16 | } |
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: | 666 / 707 |
| Version history: | 1 change(s) |
| Referenced in: | [show references] |