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

15
LINES

< > BotCompany Repo | #1027670 - singleObjectMethodProxy

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

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

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

Author comment

Began life as a copy of #1027669

download  show line numbers  debug dex   

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

No comments. add comment

Snippet ID: #1027670
Snippet name: singleObjectMethodProxy
Eternal ID of this version: #1027670/5
Text MD5: 874570ed448cd942112ca26463ae657b
Transpilation MD5: 29746395eece4ddeafe524ce72c2acdd
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:36:31
Source code size: 567 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 35 / 75
Version history: 4 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1027670 & http://1027670.tinybrain.de