Apache JDO Project - Re: JDO-109

This is Interesting: Free IT Magazines  
Home > Archive > Apache JDO Project > August 2005 > Re: JDO-109





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: JDO-109
Karan Malhi

2005-08-13, 8:45 pm

Hi Craig,

Got it. Very nicely explained.

Thanks

On 8/13/05, Craig Russell <Craig.Russell@sun.com> wrote:
>
> Hi,
>
> So here's the deepEquals method for Address, updated from:
>
> public boolean deepCompareFields(DeepEquality other,
> EqualityHelper helper) {
> Address otherAddress = (Address)other;
> return (addrid == otherAddress.addrid) &&
> helper.equals(street, otherAddress.street) &&
> helper.equals(city, otherAddress.city) &&
> helper.equals(state, otherAddress.state) &&
> helper.equals(zipcode, otherAddress.zipcode) &&
> helper.equals(country, otherAddress.country);
> }
>
> to:
>
> public boolean deepCompareFields(DeepEquality other,
> EqualityHelper helper) {
> Address otherAddress = (Address)other;
> String instanceId = "Address." + addrid + " "; // instance identifier
> return helper.equals(addrid, otherAddress.addrid, instanceId
> + "addrid") &
> helper.equals(street, otherAddress.street, instanceid +
> "street") &
> helper.equals(city, otherAddress.city, instanceid +
> "city &
> helper.equals(state, otherAddress.state, instanceid +
> "state") &
> helper.equals(zipcode, otherAddress.zipcode, instanceid
> + "zipcode") &
> helper.equals(country, otherAddress.country, instanceid
> + "country");
> }
>
> A few notes. The && is replaced with & to guarantee that all of the
> equals methods are executed and there is not an early return from the
> method because of an inequality. This way, all inequalities can be
> reported, not just the first one.
>
> The helper.equals method needs another parameter that tell what
> instance and field are being compared.
>
> Craig
>
> On Aug 13, 2005, at 12:05 PM, Craig Russell wrote:
>
>
> Craig Russell
> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
> 408 276-5638 mailto:Craig.Russell@sun.com
> P.S. A good JDO? O, Gasp!
>
>
>



--
Karan Malhi

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com