Home > Back-end >  Where I define wrapper function and functional interface for exception handling on stream
Where I define wrapper function and functional interface for exception handling on stream

Time:07-08

While using streams, I learned how to handle exceptions using functional interfaces and wrapper functions.

If so, what is the best way to structure the package?

Is it defined together in the class where stream is used? Or should I create a separate common class and define the wrapper function in it?

Thanks!

CodePudding user response:

I think it depends. If you have one instance of using this technique, then it probably makes sense to simply use an functional interface and a wrap function that are part of the class which utilizes it. If you are using this same pattern in several places (and they all have the same function interface signature) then you can define the functional interface at the package level and put the wrap function in a utility class.

  • Related