laver jeg equals og hashCode rigtigt
jeg vil bare have svar på om jeg har forstået det helt rigtigt hvordan man laver hashcode og equals.dette er en rss 2.0 channel og jeg bruger kun de 3 elementer der skal være der til at lave dem.. måske burde jeg tage nogen af de andre med?
public class Channel {
/****************************************************************
* Required channel elements;
****************************************************************/
/**
* The name of the channel.
* It's how people refer to your service.
* If you have an HTML website that contains the same information as your RSS file, t
* he title of your channel should be the same as the title of your website.
*/
private String title;
/**
* The URL to the HTML website corresponding to the channel.
*/
private URL link;
/**
* Phrase or sentence describing the channel.
*/
private String description;
public boolean equals(Object o)
{
if (o == this)
{
return true;
}
if (! (o instanceof Channel))
{
return false;
}
Channel channel = (Channel) o;
return channel.title.equals(title) && channel.link.equals(link) &&
channel.description.equals(description);
}
public int hashCode()
{
int result = 17;
result = 37 * result + title.hashCode();
result = 37 * result + link.hashCode();
result = 37 * result + description.hashCode();
return result;
}
