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

12
LINES

< > BotCompany Repo | #1025898 // tok_genRecordTransformable

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

Transpiled version (2752L) is out of date.

1  
sS tok_genRecordTransformable(S name, LPairS fields) {
2  
  ret "public O transformUsing(IF1 f) { " +
3  
    (empty(fields) ? "this;" : "ret new " + name + "("
4  
    + joinWithComma(mapPairs(fields, (type, field) ->
5  
      (eqOneOf(type, "O", "Object") ? "" : "(" + tok_varArgTypeToArray(type) + ") ")
6  
      + "f.get(" + field + ")"))
7  
    + ");")
8  
    + " }\n"
9  
    + "public void visitUsing(IVF1 f) {" +
10  
    + joinPrependSpace(map(pairsB(fields), field -> "f.get(" + field + ");"))
11  
    + " }\n";
12  
}

Author comment

Began life as a copy of #1025421

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1025898
Snippet name: tok_genRecordTransformable
Eternal ID of this version: #1025898/6
Text MD5: a042b2a471ff0d58cdec6f352f9e7bcf
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-17 00:21:01
Source code size: 498 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 241 / 393
Version history: 5 change(s)
Referenced in: [show references]