Maybe you could remove the Object here and just use generics like: Message<H,P>