fix: add equals and hashCode to Accessory and Tuning entities
This commit is contained in:
@@ -2,6 +2,7 @@ package com.onixbyte.deltaforceguide.domain.entity;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Accessory {
|
public class Accessory {
|
||||||
|
|
||||||
@@ -45,4 +46,22 @@ public class Accessory {
|
|||||||
public void removeTuning(Tuning tuning) {
|
public void removeTuning(Tuning tuning) {
|
||||||
this.tunings.remove(tuning);
|
this.tunings.remove(tuning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(o instanceof Accessory accessory)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Objects.equals(slotName, accessory.slotName)
|
||||||
|
&& Objects.equals(accessoryName, accessory.accessoryName)
|
||||||
|
&& Objects.equals(tunings, accessory.tunings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(slotName, accessoryName, tunings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.onixbyte.deltaforceguide.domain.entity;
|
package com.onixbyte.deltaforceguide.domain.entity;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Tuning {
|
public class Tuning {
|
||||||
|
|
||||||
private String tuningName;
|
private String tuningName;
|
||||||
@@ -23,4 +25,21 @@ public class Tuning {
|
|||||||
public void setTuningValue(Double tuningValue) {
|
public void setTuningValue(Double tuningValue) {
|
||||||
this.tuningValue = tuningValue;
|
this.tuningValue = tuningValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(o instanceof Tuning tuning)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Objects.equals(tuningName, tuning.tuningName)
|
||||||
|
&& Objects.equals(tuningValue, tuning.tuningValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(tuningName, tuningValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user