I'm writing a game engine in Java 8, and have prototype client code written in Groovy.
New Game objects can be created with a builder which defines everything which fills in the blanks. To simplify things, suppose the only thing the Game class needs is a mapping of keyboard inputs (which both the client and engine know about) to dynamic input events (which only the client knows about).
The input events are defined by the client, and are only ever dealt with by the client. The engine acts only to notify the client that an input has occurred which has been mapped to that input event. At that point, it then calls a method implemented by the client with that input event as the sole parameter.
My goal is to have the client code which receives the input event know at compile time the type of the event which is first provided by the client when the Game object is instantiated. My initial naive attempt at this was to turn all my engine code into generic type of
<T extends Enum<?>> but this just made a mess of everything, and solved nothing since the client code, as far as I know, only knows it's dealing a generic enum when it gets a callback.
Is this what I'm attempting even possible? Am I heading down the road with enums and generics?