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

19
LINES

< > BotCompany Repo | #1004749 // exposeMethods

JavaX fragment (include)

1  
static S exposeMethods(S s, L<S> methodNames) {
2  
  ret exposeMethods(s, toStringArray(methodNames)); // TODO: optimize
3  
}
4  
5  
static S exposeMethods(S s, S... methodNames) {
6  
  new Matches m;
7  
  if "call *" {
8  
    L l;
9  
    if (isIdentifier(m.unq(0)))
10  
      l = ll(m.unq(0));
11  
    else
12  
      l = (L) unstructure(m.unq(0)); // we used to have safeUnstructure here
13  
    S method = getString(l, 0);
14  
    if (!contains(methodNames, method))
15  
      fail("Method not allowed: " + method);
16  
    ret ok2(structure(call(mc(), method, asObjectArray(subList(l, 1)))));
17  
  }
18  
  null;
19  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004749
Snippet name: exposeMethods
Eternal ID of this version: #1004749/2
Text MD5: b9e0820cfbf7d8b885f9710c4e129e31
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-24 16:52:13
Source code size: 575 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 507 / 512
Version history: 1 change(s)
Referenced in: [show references]