Libraryless. Click here for Pure Java version (62L/1K).
1 | // return Int.MAX_VALUE if not applicable |
2 | // Lower score is better |
3 | static int methodApplicabilityScore_onTypes(Method m, Class[] argTypes) { |
4 | ret methodApplicabilityScore_onTypes((Executable) m, argTypes); |
5 | } |
6 | |
7 | static int methodApplicabilityScore_onTypes(Executable m, Class[] argTypes) { |
8 | Class<?>[] types = m.getParameterTypes(); |
9 | if (types.length != argTypes.length) ret Int.MAX_VALUE; |
10 | int score = 0; |
11 | for (int i = 0; i < types.length; i++) { |
12 | Class a = argTypes[i]; |
13 | Class c = types[i]; |
14 | if (c == a) {} // perfect match |
15 | else if (isSubclassOf(a, c)) ++score; |
16 | else ret Int.MAX_VALUE; |
17 | } |
18 | ret score; |
19 | } |
Began life as a copy of #1007854
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1020935 |
Snippet name: | methodApplicabilityScore_onTypes |
Eternal ID of this version: | #1020935/2 |
Text MD5: | 9ecd910c4d552e273440a0873cd9521d |
Transpilation MD5: | 4da32f1c7acfcc68ac9f4df8877d1317 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-02-01 20:20:14 |
Source code size: | 656 bytes / 19 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 362 / 420 |
Version history: | 1 change(s) |
Referenced in: | [show references] |