java - Reusing Supplier, Function and Consumer objects -


currently using completablefuture port streamsupport library implement chain of asynchronous tasks perform io operations.

as function , supplier objects became bit large taste, wanted move them, resulting in code like

private function<boolean, boolean> getemptybufferfunction() {     return new function<boolean, boolean>() {         @override         public boolean apply(boolean didprecedingsucceed) {             /* body */         }     } }; 

while works, curious whether practice re-created each time method called, or if better practice have implementation final objects , re-use them. i.e.

private final function<boolean, boolean> emptybufferfunction = new function<boolean, boolean>() {         @override         public boolean apply(boolean didprecedingsucceed) {             /* body */         }     } }; 


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -