The problem is, you are mixing generic and non-generic code. This will almost always lead to at least one warning about unchecked casts or raw references. Ideally you would try to change either the generic or the non-generic code, but sometimes that just isn't possible.
Fortunately, annotations can help you out. Add the following line directly above the toEvent method:
This will cause the compiler to ignore the warning. You can add this annotation to an entire class, a method, a field or a local variable.
Please note that
you should not just start using it everywhere - the warning is there for a reason. Use it only if you really have no choice, like when forced to mixing generics and non-generic code.