Java: Is it possible to always execute a certain function before other functions are called? (Like @Before in JUnit)

前端 未结 7 1657
情歌与酒
情歌与酒 2021-01-02 23:59

Is there a way to always execute a function before any other function of a class is called?

I have a class where I need to refresh some fields always before any func

7条回答
  •  无人及你
    2021-01-03 00:41

    You should use Decorator in this case. Decorator is a good choice for something like interceptor. Example here: https://msdn.microsoft.com/en-us/library/dn178467(v=pandp.30).aspx

提交回复
热议问题