Module Core : passage des attr de la clss PqtMember de private à protected; suppr des attr Date des clss Client et DataServer; Ajout méthds equals() et hashCode() à la clss Client

This commit is contained in:
Notmoo 2017-08-02 17:31:35 +02:00
parent 5e5a114085
commit fad3225524
3 changed files with 14 additions and 32 deletions

View File

@ -1,6 +1,5 @@
package com.pqt.core.entities.members; package com.pqt.core.entities.members;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
/** /**
@ -9,22 +8,14 @@ import java.util.Date;
public class Client extends PqtMember{ public class Client extends PqtMember{
private String address; private String address;
private Date lastUpdate;
public Client() { public Client() {
super(-1, PqtMemberType.CLIENT); super(-1, PqtMemberType.CLIENT);
} }
public Client(int id, String address) { public Client(long id, String address) {
super(id, PqtMemberType.CLIENT); super(id, PqtMemberType.CLIENT);
this.address = address; 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() { public String getAddress() {
@ -35,11 +26,18 @@ public class Client extends PqtMember{
this.address = address; this.address = address;
} }
public Date getLastUpdate() { @Override
return lastUpdate; 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) { @Override
this.lastUpdate = lastUpdate; public int hashCode() {
return address.hashCode() + type.hashCode() + Integer.class.cast(id);
} }
} }

View File

@ -1,12 +1,10 @@
package com.pqt.core.entities.members; package com.pqt.core.entities.members;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
public class DataServer extends PqtMember{ public class DataServer extends PqtMember{
private String address; private String address;
private Date lastUpdate;
public DataServer() { public DataServer() {
super(-1, PqtMemberType.DATA_SERVER); super(-1, PqtMemberType.DATA_SERVER);
@ -15,15 +13,8 @@ public class DataServer extends PqtMember{
public DataServer(long id, String address) { public DataServer(long id, String address) {
super(id, PqtMemberType.DATA_SERVER); super(id, PqtMemberType.DATA_SERVER);
this.address = address; 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() { public String getAddress() {
return address; return address;
} }
@ -32,11 +23,4 @@ public class DataServer extends PqtMember{
this.address = address; this.address = address;
} }
public Date getLastUpdate() {
return lastUpdate;
}
public void setLastUpdate(Date lastUpdate) {
this.lastUpdate = lastUpdate;
}
} }

View File

@ -6,8 +6,8 @@ import java.io.Serializable;
public class PqtMember implements ILoggable, Serializable { public class PqtMember implements ILoggable, Serializable {
private long id; protected long id;
private PqtMemberType type; protected PqtMemberType type;
public PqtMember() { public PqtMember() {
} }