backend/buisnesslogic/src/main/java/com/plannaplan/models/MatchData.java
Marcin Woźniak 1c12a778af
Checkpoint: Added ExchangeServiceTest
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-12 13:04:57 +01:00

50 lines
1.3 KiB
Java

package com.plannaplan.models;
import com.plannaplan.entities.Assignment;
public class MatchData {
private Assignment assignmentOne;
private Assignment assignmentTwo;
public MatchData(Assignment assignmentOne, Assignment assignmentTwo) {
this.assignmentOne = assignmentOne;
this.assignmentTwo = assignmentTwo;
}
public Assignment getAssignmentTwo() {
return assignmentTwo;
}
public Assignment getAssignmentOne() {
return assignmentOne;
}
@Override
public int hashCode() {
return this.assignmentOne.hashCode() + this.assignmentTwo.hashCode();
}
@Override
public boolean equals(Object o) {
// If the object is compared with itself then return true
if (o == this) {
return true;
}
/*
* Check if o is an instance of Complex or not "null instanceof [type]" also
* returns false
*/
if (!(o instanceof MatchData)) {
return false;
}
// typecast o to Complex so that we can compare data members
MatchData c = (MatchData) o;
// Compare the data members and return accordingly
return (this.assignmentOne.equals(c.getAssignmentOne()) && this.assignmentTwo.equals(c.getAssignmentTwo())) || (this.assignmentOne.equals(c.getAssignmentTwo()) && this.assignmentTwo.equals(c.getAssignmentOne()));
}
}