Junilu Lacar wrote:So, if you only care about certain fields that you want to explicitly list out, why use reflection? That's the smell. Using reflection to exclude specific fields makes sense because you won't have to change the code if that exclusion list doesn't change but the objects are modified to include more fields that should be checked. In your case, it doesn't make sense to use reflection because you want to list fields to include. If that list changes, you'll still have to change the code. You gain nothing by using reflection. Since reflection is costly, you're paying for a service that is of no practical use to you in the context of the problem you're trying to solve. That's like paying for premium cable channels that you don't ever watch. So what's the point?
Got your Point, thanks a bunch ! and I think for the same reason they don't have include fields in api but exclude fields only.