How to create custom annotation in java?

后端 未结 3 1147
难免孤独
难免孤独 2021-02-01 23:28

I want to create custom annotation in java for DirtyChecking. Like I want to compare two string values using this annotation and after comparing it will return a

3条回答
  •  深忆病人
    2021-02-02 00:09

    To answer your second question: your annotation can't return a value. The class which processes your annotation can do something with your object. This is commonly used for logging for example. I'm not sure if using an annotation for checking if an object is dirty makes sense except you want to throw an exception in this case or inform some kind of DirtyHandler.

    For your first question: you could really spent some effort in finding this yourself. There are enough information here on stackoverflow and the web.

提交回复
热议问题