static <A> A optParam(ThreadLocal<A> tl, A defaultValue) { ret optPar(tl, defaultValue); } static <A> A optParam(ThreadLocal<A> tl) { ret optPar(tl); } static O mapMethodLike optParam(S name, Map params) { ret mapGet(params, name); } // now also takes a map as single array entry static <A> A optParam(O[] opt, S name, A defaultValue) { int n = l(opt); if (n == 1 && opt[0] instanceof Map) { Map map = cast opt[0]; ret map.containsKey(name) ? (A) map.get(name) : defaultValue; } if (!even(l(opt))) fail("Odd parameter length"); for (int i = 0; i < l(opt); i += 2) if (eq(opt[i], name)) ret (A) opt[i+1]; ret defaultValue; } sO optParam(O[] opt, S name) { ret optParam(opt, name, null); } sO mapMethodLike optParam(S name, O[] params) { ret optParam(params, name); }
Began life as a copy of #1006679
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1007397 |
| Snippet name: | optParam - synonym of optPar - get optional parameter from ThreadLocal |
| Eternal ID of this version: | #1007397/12 |
| Text MD5: | 0a7e54de17f1d576e3ec13303b1eee2d |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-01-14 19:36:13 |
| Source code size: | 842 bytes / 33 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 929 / 977 |
| Version history: | 11 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1009998 - boolOptParam - get boolean optional parameter - defaults to false #1027361 - optPar_ignoreOddLength |