users@jsr311.java.net

Re: MediaType.isComaptible

From: Reto Bachmann-Gmür <reto_at_gmuer.ch>
Date: Wed, 13 Aug 2008 08:26:26 +0200

Marc Hadley wrote:
> On Aug 12, 2008, at 5:15 PM, Reto Bachmann-Gmür wrote:
>
>> According to the API MediaType.isComaptible returns "true if other is
>> a subtype of this media type, false otherwise".
>
> That could probably do with a rewording. Something like "returns true if
> this is compatible with other, false otherwise".
Without definining "compatible" this doesn't make things more clear.
> [...]
>>Assert.assertTrue(MediaType.WILDCARD_TYPE.isCompatible(type1));
We both agree */* is compatible with image/jpeg
>[...]
>>
>> Assert.assertFalse(type1.isCompatible(MediaType.WILDCARD_TYPE));
>>
> image/jpeg is compatible with */* so I think the assertion is wrong
> given the clarified javadoc suggested above.

I don't think that a symmetric compatibility function is of much use, so
I would stuck with the current asymmetric definition clarifying the
wording with: "true if other is equals to or a subtype of this media
type, false otherwise".

In other words: A.isCompatible(B) is true if and only of the extension
of A is a superset of the extension of B and not, as with your proposal
if any of the extensions is a subset of the other.

reto