ianlee-dev / facebook-java-api

Automatically exported from code.google.com/p/facebook-java-api
0 stars 0 forks source link

Implement equals(), hashCode() and toString() on the JAXB classes #162

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Use the JAXB plugin to generate these methods so that we can put the JAXB
results into Collections and expect them to behave correctly.

Original issue reported on code.google.com by david.j....@googlemail.com on 15 Jan 2009 at 9:18

GoogleCodeExporter commented 8 years ago
Based on group email:

Hi,

 Thanks for the great work on the API.
I'm using the JAXB client, and I am admittedly new to using JAXB.
I used a free plugin in Intellij to: "Generate files from your XSD
schemas with JAXB 2.0 XJC generator"
Quite handy.
I was writing integration tests such as:
Create a new album on FB with certain properties set.
Get all albums for that user from FB
Assert that the list of all actual albums contains the expectedAlbum
that I just created.

I ran into a snag because equals and hashCode were not overriden in
the JAXB generated classes. (same w/ the ones in the lib JAR.)

So, I made a quick fix by dropping this into my generated
com.google.code.facebookapi.schema.Album class.

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

       public boolean equals(final Object obj) {
               return EqualsBuilder.reflectionEquals(this, obj);
   }

       public int hashCode() {
               return HashCodeBuilder.reflectionHashCode(this);
       }

---
I did a little research and found these projects for automatically
overriding equals(), hashCode() and toString() in JAXB generated
classes.

https://jaxb2-commons.dev.java.net/commons-lang-plugin/
https://hyperjaxb3.dev.java.net/docs/tools/plugin/index.html

Does this look like a worthwhile addition to the FB API release jar?

Thanks,

Ed

Original comment by david.j....@googlemail.com on 15 Jan 2009 at 9:19

GoogleCodeExporter commented 8 years ago

Original comment by david.j....@googlemail.com on 15 Jan 2009 at 9:24