Marc Hadley wrote:
> On Aug 13, 2008, at 2:26 AM, Reto Bachmann-Gmür wrote:
>
>> 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.
>>
> The method is currently commutative so both
> "*/*".isCompatible("image/jpeg") and "image/jpeg".isCompatible("*/*")
> return true.
>
> I'll have to think about the implications of making it asymmetric. Can
> you say more about why you think the current commutative behavior isn't
> of much use ?
>
I have found no requirement for asymmetric matching.
I make use of the commutative behavior all the time. Namely i do not
care what on order of operands "image/jpeg" and "image/*", one could be
defined in the accept header and the other could be defined in @Produces
on a resource method or on a message body reader/writer, which in what
does not matter for compatibility purposes.
For example, the Accept header could be:
Accept: image/*
and i could have a resource method:
@Produces("image/jpeg")
public Image getJpegImage() { ... }
Or the Accept header could be:
Accept: image/jpeg
and i could have a resource method:
@Produces("image/*")
public Response getGeneralImage() { ... }
Changing this method to be asymmetric will essentially render it useless.
Paul.
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109