mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-12-22 23:41:09 +00:00
Suppr clss Field, modif attr fields dans clss Message, ajout méthds hasField(..) et getField(...) dans clss Message
This commit is contained in:
parent
fbdb2682cc
commit
d2d45d93a0
Binary file not shown.
@ -1,22 +0,0 @@
|
||||
package com.pqt.core.entities.messages;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Field implements Serializable{
|
||||
|
||||
private String header;
|
||||
private String data;
|
||||
|
||||
public Field(String header, String data) {
|
||||
this.header = header;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
}
|
@ -3,11 +3,13 @@ package com.pqt.core.entities.messages;
|
||||
import com.pqt.core.entities.members.PqtMember;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Message {
|
||||
|
||||
private List<Field> fields;
|
||||
private Map<String, String> fields;
|
||||
private MessageType type;
|
||||
private PqtMember emitter, receiver;
|
||||
|
||||
@ -15,17 +17,27 @@ public class Message {
|
||||
this(type, emitter, receiver, null);
|
||||
}
|
||||
|
||||
public Message(MessageType type, PqtMember emitter, PqtMember receiver, List<Field> fields) {
|
||||
public Message(MessageType type, PqtMember emitter, PqtMember receiver, Map<String, String> fields) {
|
||||
this.emitter = emitter;
|
||||
this.receiver = receiver;
|
||||
this.type = type;
|
||||
this.fields = new ArrayList<>();
|
||||
this.fields = new HashMap<>();
|
||||
if(fields!=null)
|
||||
this.fields.addAll(fields);
|
||||
for(String key : fields.keySet()){
|
||||
this.fields.put(key, fields.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
public List<Field> getFields() {
|
||||
return new ArrayList<>(fields);
|
||||
public Map<String, String> getFields() {
|
||||
return new HashMap<>(fields);
|
||||
}
|
||||
|
||||
public boolean hasField(String header){
|
||||
return fields.containsKey(header);
|
||||
}
|
||||
|
||||
public String getField(String header){
|
||||
return fields.get(header);
|
||||
}
|
||||
|
||||
public PqtMember getEmitter() {
|
||||
|
Loading…
Reference in New Issue
Block a user