From fad322552437ccbd639d214b39e7b5468701a515 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Wed, 2 Aug 2017 17:31:35 +0200 Subject: [PATCH] =?UTF-8?q?Module=20Core=20:=20passage=20des=20attr=20de?= =?UTF-8?q?=20la=20clss=20PqtMember=20de=20private=20=C3=A0=20protected;?= =?UTF-8?q?=20suppr=20des=20attr=20Date=20des=20clss=20Client=20et=20DataS?= =?UTF-8?q?erver;=20Ajout=20m=C3=A9thds=20equals()=20et=20hashCode()=20?= =?UTF-8?q?=C3=A0=20la=20clss=20Client?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/pqt/core/entities/members/Client.java | 26 +++++++++---------- .../pqt/core/entities/members/DataServer.java | 16 ------------ .../pqt/core/entities/members/PqtMember.java | 4 +-- 3 files changed, 14 insertions(+), 32 deletions(-) diff --git a/Workspace/core/src/main/java/com/pqt/core/entities/members/Client.java b/Workspace/core/src/main/java/com/pqt/core/entities/members/Client.java index 0d667489..980d0be3 100644 --- a/Workspace/core/src/main/java/com/pqt/core/entities/members/Client.java +++ b/Workspace/core/src/main/java/com/pqt/core/entities/members/Client.java @@ -1,6 +1,5 @@ package com.pqt.core.entities.members; -import java.io.Serializable; import java.util.Date; /** @@ -9,22 +8,14 @@ import java.util.Date; public class Client extends PqtMember{ private String address; - private Date lastUpdate; public Client() { super(-1, PqtMemberType.CLIENT); } - public Client(int id, String address) { + public Client(long id, String address) { super(id, PqtMemberType.CLIENT); this.address = address; - this.lastUpdate = new Date(); - } - - public Client(int id, String address, Date lastUpdate) { - super(id, PqtMemberType.CLIENT); - this.address = address; - this.lastUpdate = lastUpdate; } public String getAddress() { @@ -35,11 +26,18 @@ public class Client extends PqtMember{ this.address = address; } - public Date getLastUpdate() { - return lastUpdate; + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Client client = (Client) o; + + return address.equals(client.address) && id==client.id && type.equals(client.type); } - public void setLastUpdate(Date lastUpdate) { - this.lastUpdate = lastUpdate; + @Override + public int hashCode() { + return address.hashCode() + type.hashCode() + Integer.class.cast(id); } } diff --git a/Workspace/core/src/main/java/com/pqt/core/entities/members/DataServer.java b/Workspace/core/src/main/java/com/pqt/core/entities/members/DataServer.java index 9804f487..ffa4dfda 100644 --- a/Workspace/core/src/main/java/com/pqt/core/entities/members/DataServer.java +++ b/Workspace/core/src/main/java/com/pqt/core/entities/members/DataServer.java @@ -1,12 +1,10 @@ package com.pqt.core.entities.members; -import java.io.Serializable; import java.util.Date; public class DataServer extends PqtMember{ private String address; - private Date lastUpdate; public DataServer() { super(-1, PqtMemberType.DATA_SERVER); @@ -15,15 +13,8 @@ public class DataServer extends PqtMember{ public DataServer(long id, String address) { super(id, PqtMemberType.DATA_SERVER); this.address = address; - this.lastUpdate = new Date(); } - public DataServer(long id, String address, Date lastUpdate) { - super(id, PqtMemberType.DATA_SERVER); - this.address = address; - this.lastUpdate = lastUpdate; - } - public String getAddress() { return address; } @@ -32,11 +23,4 @@ public class DataServer extends PqtMember{ this.address = address; } - public Date getLastUpdate() { - return lastUpdate; - } - - public void setLastUpdate(Date lastUpdate) { - this.lastUpdate = lastUpdate; - } } diff --git a/Workspace/core/src/main/java/com/pqt/core/entities/members/PqtMember.java b/Workspace/core/src/main/java/com/pqt/core/entities/members/PqtMember.java index 94399c6b..cc5cb4a9 100644 --- a/Workspace/core/src/main/java/com/pqt/core/entities/members/PqtMember.java +++ b/Workspace/core/src/main/java/com/pqt/core/entities/members/PqtMember.java @@ -6,8 +6,8 @@ import java.io.Serializable; public class PqtMember implements ILoggable, Serializable { - private long id; - private PqtMemberType type; + protected long id; + protected PqtMemberType type; public PqtMember() { }