On Thu, Dec 20, 2012 at 3:34 PM, jbright <[email protected]> wrote:

> Thanks for your suggestion, perhaps that won't work.
>
> In my post I clearly mentioned that I get the mediaType as
> /"application/json;charset=UTF-8"/
>
> MediaType.APPLICATION_JSON_TYPE is = to "application/json"
>
> so when you do like this :(
>
> MediaType mediaType = httpHeaders.getMediaType();
>
> if(mediaType.equals(MediaType.APPLICATION_JSON_TYPE))  returns false .....
>
> in reality its like this
>
> if("application/json;charset=UTF-8".equals("application/json"))
>
> Yes, I know, that was simple an example of a correct way to compare
MediaTypes. I also mentioned that you can create your own MediaType
instance if the one you need is not present in MediaType.
application/json with charset property obviously is not present, so you
have to define your own instance as Sergey suggested (MediaType.valueOf) ;-)

the equals method in the MediaType is like this
>
> public boolean equals(Object obj) {
>         if (obj == null)
>             return false;
>         if (!(obj instanceof MediaType))
>             return false;
>         MediaType other = (MediaType)obj;
>         return (this.type.equalsIgnoreCase(other.type)
>                 && this.subtype.equalsIgnoreCase(other.subtype)
>                 *&& this.parameters.equals(other.parameters)*);
>     }
>
> see the bold item above...
>
>
> Yes, exactly. See what I wrote above :-)


>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/MediaType-equals-Object-obj-method-issue-tp5720558p5720571.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>

Reply via email to