From ece6ef133cf69ca275e641b2133a7555690cbae2 Mon Sep 17 00:00:00 2001 From: Richard Reiber Date: Sat, 5 Jun 2021 22:21:44 +0200 Subject: [PATCH] refactor: generated equals and hashcode for Packet --- .../server/lobby/pipelining/Packet.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/lobby/pipelining/Packet.java b/Server/src/main/java/uulm/teamname/marvelous/server/lobby/pipelining/Packet.java index e3cab2f..1762234 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/lobby/pipelining/Packet.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/lobby/pipelining/Packet.java @@ -4,10 +4,7 @@ import uulm.teamname.marvelous.gamelibrary.requests.Request; import uulm.teamname.marvelous.gamelibrary.requests.RequestType; import uulm.teamname.marvelous.server.lobbymanager.Participant; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; +import java.util.*; public class Packet extends ArrayList { @@ -41,4 +38,17 @@ public class Packet extends ArrayList { 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); + } }