Re: JDO-109
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache JDO Project > Re: JDO-109




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Re: JDO-109  
Michael Bouschen


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-15-05 10:45 PM

Hi Craig, hi Karan,

my $0.02:

I like the idea of adding a new parameter to the EqualityHelper.equals
method specifying the instance and the field being compared.

The EqualityHelper could manage a list of differences. The list is
updated each time EqualityHelper.equals returns false. A new method
getDifferences (maybe you know a better name) returns th current list of
differences managed by the EqualityHelper instance. This allows us to
give a better error message in case the CompletenessTest fails because
of unexpected instances in the datastore.

As Craig already pointed out: any == comparison needs to be replaced by
EqualityHelper.equals calls. That means, we need to add equals methods
for primitives types. And we cannot use a conditional and (&&) anymore,
because we want to know all the differences.

Regards Michael

> 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!
>
>


--
Michael Bouschen		Tech@Spree Engineering GmbH
mailto:mbo.tech@spree.de	http://www.tech.spree.de/
Tel.:++49/30/235 520-33		Buelowstr. 66
Fax.:++49/30/2175 2012		D-10783 Berlin






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:57 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register