In my resource, I fully expected the following to work:

   if (entity.getMediaType().equals(MediaType.APPLICATION_JSON)) {

but I was surprised to discover that it did not because a parameter
had been set for character encoding on the request and the 
MediaType.equals() is implemented to look at those. That makes no sense to me.

Then I discovered the workaround:

   if (entity.getMediaType().equals(MediaType.APPLICATION_JSON, true)) {

The additional argument says to ignore parameters. So the two concerns I
have are:
1) MediaType.equals() should compare media types only and that should be
   the default.
2) If some other capability is required, call it something other than "equals."

I guess another question would be, why was the encoding set in the first place?

Sean

Reply via email to