JodaOrg/joda-time — pull request #98 by rowanhill (2013-12-10 00:00:00+00:00)
Title: Canonically order partial fields to allow comparison

Hi,

Issue #96 describes a problem in which Partials made from equal (but differently ordered) fields are not considered equal. This change fixes that (and adds tests to support the fix) by enforcing a canonical ordering of fields on construction of the Partial.

I'm not certain that this is better than disallowing the construction - in particular, I don't know if it will have any unintended side-effects (but it doesn't break any tests). I'm also not keen on the large amounts of logic about ordering DateTimeFieldTypes now collected in the Partial class (and its new private comparator) - if there's an obviously better place for it to go, please let me know.

As far as I can tell, the only affected case is where a) the fields are similar in that compareTo() returns 0, but different in that equals() returns false and b) one of the fields has a range duration and the other does not. I've ordered such fields on their name.

I _think_ in all other cases the Partial constructor will reject the fields as being either duplicates or out of order, but I could be wrong - if so, let me know, and I'll add more test cases.

Thanks,
Rowan