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

15
LINES

< > BotCompany Repo | #1027674 // singleObjectMethodProxy2 - with 2 different method names

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

Libraryless. Click here for Pure Java version (2247L/14K).

static <A> A singleObjectMethodProxy2(Class<A> intrface, O object, S invokedMethodName, S targetMethodName) {
  ret proxyFromInvocationHandler(intrface, new InvocationHandler {
    public O invoke(O proxy, Method method, O[] args) {
      S mname = method.getName();
      ifdef singleObjectMethodProxy2_debug
        print("Proxy method called: " + mname + " " + toList(args));
      endifdef
      if (mname.equals(invokedMethodName))
        ret call(object, targetMethodName, unnull(args));
      if (mname.equals("toString"))
        ret "proxy for method " + targetMethodName;
      null;
    }
  });
}

Author comment

Began life as a copy of #1027670

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: #1027674
Snippet name: singleObjectMethodProxy2 - with 2 different method names
Eternal ID of this version: #1027674/1
Text MD5: 8dcea9a0d72eee31467c8b5c24468ba6
Transpilation MD5: 0ab700df25b77fd948c6187b457bf266
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-29 23:39:54
Source code size: 622 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 157 / 224
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)