refactor: generated equals and hashcode for Packet

This commit is contained in:
Richard Reiber 2021-06-05 22:21:44 +02:00
parent 8ee3e22dab
commit ece6ef133c

View File

@ -4,10 +4,7 @@ import uulm.teamname.marvelous.gamelibrary.requests.Request;
import uulm.teamname.marvelous.gamelibrary.requests.RequestType; import uulm.teamname.marvelous.gamelibrary.requests.RequestType;
import uulm.teamname.marvelous.server.lobbymanager.Participant; import uulm.teamname.marvelous.server.lobbymanager.Participant;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
public class Packet extends ArrayList<Request> { public class Packet extends ArrayList<Request> {
@ -41,4 +38,17 @@ public class Packet extends ArrayList<Request> {
return origin; return origin;
} }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
Packet packet = (Packet) o;
return Objects.equals(origin, packet.origin);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), origin);
}
} }