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

13
LINES

< > BotCompany Repo | #1026077 // recordFromStrings_smartConvert

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2325L/15K).

static <A> A nuLike recordFromStrings_smartConvert(Class<A> recordType, LS strings) ctex {
  int n = l(strings);
  L<Constructor> constrs = constructorsWithNumberOfArguments(recordType, n);
  if (empty(constrs)) fail("No constructor with " + nArguments(n) + " in " + recordType);
  
  Constructor con = first(constrs);
  Class[] types = con.getParameterTypes();
  O[] args = new O[n];
  for i to n:
    args[i] = smartValueConvert1(types[i], strings.get(i));
  makeAccessible(con);
  ret (A) con.newInstance(args);
}

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: 209 / 304
Version history: 1 change(s)
Referenced in: [show references]