Libraryless. Click here for Pure Java version (2325L/15K).
1 | static <A> A nuLike recordFromStrings_smartConvert(Class<A> recordType, LS strings) ctex {
|
2 | int n = l(strings); |
3 | L<Constructor> constrs = constructorsWithNumberOfArguments(recordType, n); |
4 | if (empty(constrs)) fail("No constructor with " + nArguments(n) + " in " + recordType);
|
5 | |
6 | Constructor con = first(constrs); |
7 | Class[] types = con.getParameterTypes(); |
8 | O[] args = new O[n]; |
9 | for i to n: |
10 | args[i] = smartValueConvert1(types[i], strings.get(i)); |
11 | makeAccessible(con); |
12 | ret (A) con.newInstance(args); |
13 | } |
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1026077 |
| Snippet name: | recordFromStrings_smartConvert |
| Eternal ID of this version: | #1026077/2 |
| Text MD5: | 9005e21e3dcf813a18a2ec4d7c964cbd |
| Transpilation MD5: | 6fe1f53dae0fd7bac0c0771c8415b415 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-11-19 13:44:59 |
| Source code size: | 528 bytes / 13 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 489 / 616 |
| Version history: | 1 change(s) |
| Referenced in: | [show references] |