core-java icon indicating copy to clipboard operation
core-java copied to clipboard

Allow optional `@React` annotation of `Policy.whenever()` methods

Open alexander-yevsyukov opened this issue 2 years ago • 1 comments

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:

  1. 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.

  2. 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?

alexander-yevsyukov avatar Oct 31 '23 21:10 alexander-yevsyukov

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.

alexander-yevsyukov avatar Oct 31 '23 21:10 alexander-yevsyukov