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.

sS tok_genRecordTransformable(S name, LPairS fields) {
  ret "public O transformUsing(IF1 f) { " +
    (empty(fields) ? "this;" : "ret new " + name + "("
    + joinWithComma(mapPairs(fields, (type, field) ->
      (eqOneOf(type, "O", "Object") ? "" : "(" + tok_varArgTypeToArray(type) + ") ")
      + "f.get(" + field + ")"))
    + ");")
    + " }\n"
    + "public void visitUsing(IVF1 f) {" +
    + joinPrependSpace(map(pairsB(fields), field -> "f.get(" + field + ");"))
    + " }\n";
}

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: 239 / 391
Version history: 5 change(s)
Referenced in: [show references]