Need to use `com.google.common.reflect.TypeToken` to preserve generics. This is possible with things like `BasicConfigKey.builder(new TypeToken<Function<Entity,Integer>>() {})...build()`, but we should support it in the overloaded constructor too. It's ugly but necessary having to create the anonymous class unfortunately, so code ends up looking as nasty as the cast but without the generics warning.

(For a future pull request...)