Hallo Leute,
soweit ich weiß die Gleichheit von zweil Listen wird anhand der equals-Methode deren Elemente festgestellt. Allerdings wird die Equals-Methode nicht aufgerufen. So sieht der Code aus:
Feedback
Comment-Klasse
Um festzustellen warum zwei Feedbacks nicht gleich sind habe ich einen break-Point in der Methode Feedback.equals und Comment.equals gesetzt. Allerdings Comment.equals wird nicht aufgerufen.
Warum ist es so? Hat jemand eine Idee?
Gruß,
madlena
soweit ich weiß die Gleichheit von zweil Listen wird anhand der equals-Methode deren Elemente festgestellt. Allerdings wird die Equals-Methode nicht aufgerufen. So sieht der Code aus:
Feedback
Java:
protected List<Comment> feedbackComments = new ArrayList<Comment>();
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((OBJECT_REF_ID == null) ? 0 : OBJECT_REF_ID.hashCode());
result = prime * result
+ ((OBJECT_REF_TYP == null) ? 0 : OBJECT_REF_TYP.hashCode());
result = prime * result + ((author == null) ? 0 : author.hashCode());
result = prime * result
+ ((comments == null) ? 0 : comments.hashCode());
result = prime * result + ((content == null) ? 0 : content.hashCode());
result = prime * result + ((created == null) ? 0 : created.hashCode());
result = prime * result + (deleted ? 1231 : 1237);
result = prime * result + ((editor == null) ? 0 : editor.hashCode());
result = prime
* result
+ ((feedbackComments == null) ? 0 : feedbackComments.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result
+ ((modified == null) ? 0 : modified.hashCode());
result = prime * result
+ ((ontologyURI == null) ? 0 : ontologyURI.hashCode());
result = prime * result
+ ((ontologyVersion == null) ? 0 : ontologyVersion.hashCode());
result = prime * result + (readyToSync ? 1231 : 1237);
result = prime * result
+ ((statusId == null) ? 0 : statusId.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Feedback other = (Feedback) obj;
if (OBJECT_REF_ID == null) {
if (other.OBJECT_REF_ID != null)
return false;
} else if (!OBJECT_REF_ID.equals(other.OBJECT_REF_ID))
return false;
if (OBJECT_REF_TYP == null) {
if (other.OBJECT_REF_TYP != null)
return false;
} else if (!OBJECT_REF_TYP.equals(other.OBJECT_REF_TYP))
return false;
if (author == null) {
if (other.author != null)
return false;
} else if (!author.equals(other.author))
return false;
if (comments == null) {
if (other.comments != null)
return false;
} else if (!comments.equals(other.comments))
return false;
if (content == null) {
if (other.content != null)
return false;
} else if (!content.equals(other.content))
return false;
if (created == null) {
if (other.created != null)
return false;
} else if (!created.equals(other.created))
return false;
if (deleted != other.deleted)
return false;
if (editor == null) {
if (other.editor != null)
return false;
} else if (!editor.equals(other.editor))
return false;
if (feedbackComments == null) {
if (other.feedbackComments != null)
return false;
} else if (!feedbackComments.equals(other.feedbackComments))
return false;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (modified == null) {
if (other.modified != null)
return false;
} else if (!modified.equals(other.modified))
return false;
if (ontologyURI == null) {
if (other.ontologyURI != null)
return false;
} else if (!ontologyURI.equals(other.ontologyURI))
return false;
if (ontologyVersion == null) {
if (other.ontologyVersion != null)
return false;
} else if (!ontologyVersion.equals(other.ontologyVersion))
return false;
if (readyToSync != other.readyToSync)
return false;
if (statusId == null) {
if (other.statusId != null)
return false;
} else if (!statusId.equals(other.statusId))
return false;
return true;
}
Comment-Klasse
Java:
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((attachment == null) ? 0 : attachment.hashCode());
result = prime * result + ((author == null) ? 0 : author.hashCode());
result = prime * result + ((created == null) ? 0 : created.hashCode());
result = prime * result + (createdByEditor ? 1231 : 1237);
result = prime * result + (read ? 1231 : 1237);
result = prime * result + ((text == null) ? 0 : text.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Comment other = (Comment) obj;
if (attachment == null) {
if (other.attachment != null)
return false;
} else if (!attachment.equals(other.attachment))
return false;
if (author == null) {
if (other.author != null)
return false;
} else if (!author.equals(other.author))
return false;
if (created == null) {
if (other.created != null)
return false;
} else if (!created.equals(other.created))
return false;
if (createdByEditor != other.createdByEditor)
return false;
if (read != other.read)
return false;
if (text == null) {
if (other.text != null)
return false;
} else if (!text.equals(other.text))
return false;
return true;
}
Um festzustellen warum zwei Feedbacks nicht gleich sind habe ich einen break-Point in der Methode Feedback.equals und Comment.equals gesetzt. Allerdings Comment.equals wird nicht aufgerufen.
Warum ist es so? Hat jemand eine Idee?
Gruß,
madlena