I've just tried to create a couple of stub Policy classes and forgot to add @React annotation on the implemented whenever() methods. This resulted in runtime exception pointing that the contract for the methods is not correct.
We can make it more convenient for the user, making the @React annotation optional in this case (just for the additional clarity). Here's why:
The Policy class assumes that there is only one even handled by it. We don't need to find annotated methods to see what signals a class handles. We know there's gonna be only one. We even check for this on runtime.
The method whenever() is abstract. We know it's going to be overridden. We know the event type handled by the policy by the generic parameter of the class (and the method). Why force the annotation?
There is a GreedyPolicy test env. class in ProtoData code with the associated test. It should be migrated to core-java as an additional result of this issue.
I've just tried to create a couple of stub
Policy
classes and forgot to add@React
annotation on the implementedwhenever()
methods. This resulted in runtime exception pointing that the contract for the methods is not correct.We can make it more convenient for the user, making the
@React
annotation optional in this case (just for the additional clarity). Here's why:The
Policy
class assumes that there is only one even handled by it. We don't need to find annotated methods to see what signals a class handles. We know there's gonna be only one. We even check for this on runtime.The method
whenever()
is abstract. We know it's going to be overridden. We know the event type handled by the policy by the generic parameter of the class (and the method). Why force the annotation?