Advertisement
Nashev

java callback closure with argument

Jun 19th, 2017
698
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1.     public interface nodeProcessCallback {void run(Element item);}
  2.  
  3.     protected void processNodes(String tagName, nodeProcessCallback callback) {
  4.         ....
  5.         callback.run(item);
  6.         ....
  7.     }
  8.    
  9.     private void processTable(Element item){
  10.         ....
  11.     }
  12.  
  13.     public void execute() throws Exception {
  14.         ....
  15.         // send processTable as callback:
  16.         processNodes("TABLE", (item) -> processTable(item));
  17.         ....
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement