diff --git a/bot-domain/bot-domain-main/src/main/java/dev/struchkov/godfather/main/domain/content/Mail.java b/bot-domain/bot-domain-main/src/main/java/dev/struchkov/godfather/main/domain/content/Mail.java index 56fb81f..9e1e921 100644 --- a/bot-domain/bot-domain-main/src/main/java/dev/struchkov/godfather/main/domain/content/Mail.java +++ b/bot-domain/bot-domain-main/src/main/java/dev/struchkov/godfather/main/domain/content/Mail.java @@ -1,5 +1,6 @@ package dev.struchkov.godfather.main.domain.content; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @@ -15,6 +16,7 @@ import java.util.List; @Getter @Setter +@EqualsAndHashCode(onlyExplicitlyIncluded = true) public class Mail extends Message { public static final String TYPE = "MAIL"; @@ -43,26 +45,6 @@ public class Mail extends Message { contentType = ContentType.MAIL; } - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public List getAttachments() { - return attachments; - } - public void addAttachment(Attachment attachment) { this.attachments.add(attachment); } @@ -71,12 +53,4 @@ public class Mail extends Message { this.attachments.addAll(attachments); } - public List getForwardMail() { - return forwardMail; - } - - public void setForwardMail(List forwardMail) { - this.forwardMail = forwardMail; - } - } diff --git a/bot-domain/bot-domain-main/src/main/java/dev/struchkov/godfather/main/domain/content/Message.java b/bot-domain/bot-domain-main/src/main/java/dev/struchkov/godfather/main/domain/content/Message.java index e8176e9..1fc374b 100644 --- a/bot-domain/bot-domain-main/src/main/java/dev/struchkov/godfather/main/domain/content/Message.java +++ b/bot-domain/bot-domain-main/src/main/java/dev/struchkov/godfather/main/domain/content/Message.java @@ -44,7 +44,7 @@ public abstract class Message implements DeliverableText { */ protected String text; - protected Map payload = new HashMap<>(); + protected Map payload = new HashMap<>(); protected Message(Message source) { this.id = source.getId(); @@ -58,18 +58,14 @@ public abstract class Message implements DeliverableText { protected Message() { } - public Map getPayload() { - return payload; - } - - public void setPayload(ContextKey key, T value) { + public void addPayload(ContextKey key, T value) { if (checkNotNull(value)) { - payload.put(key, value); + payload.put(key.getValue(), value); } } public Optional getPayLoad(ContextKey contextKey) { - return Optional.ofNullable(payload.get(contextKey)) + return Optional.ofNullable(payload.get(contextKey.getValue())) .map(value -> (T) value); } diff --git a/bot-domain/bot-domain-quarkus/src/main/java/dev/struchkov/godfather/quarkus/domain/BoxAnswer.java b/bot-domain/bot-domain-quarkus/src/main/java/dev/struchkov/godfather/quarkus/domain/BoxAnswer.java index bd9f4ad..efbcc65 100644 --- a/bot-domain/bot-domain-quarkus/src/main/java/dev/struchkov/godfather/quarkus/domain/BoxAnswer.java +++ b/bot-domain/bot-domain-quarkus/src/main/java/dev/struchkov/godfather/quarkus/domain/BoxAnswer.java @@ -51,7 +51,7 @@ public class BoxAnswer { /** * Полезная нагрузка для реализаций. */ - protected Map payload; + protected Map payload; private BoxAnswer(Builder builder) { message = builder.message; @@ -112,19 +112,22 @@ public class BoxAnswer { } } - public Map getPayload() { + public Map getPayload() { return payload; } public void setPayload(ContextKey key, T value) { if (checkNotNull(value)) { - payload.put(key, value); + payload.put(key.getValue(), value); } } public Optional getPayLoad(ContextKey contextKey) { - return Optional.ofNullable(payload.get(contextKey)) - .map(value -> (T) value); + if (checkNotNull(payload)) { + return Optional.ofNullable(payload.get(contextKey.getValue())) + .map(value -> (T) value); + } + return Optional.empty(); } public static final class Builder { @@ -134,7 +137,7 @@ public class BoxAnswer { private boolean replace; private String replaceMessageId; private String recipientPersonId; - private Map payload = new HashMap<>(); + private Map payload = new HashMap<>(); private Builder() { } @@ -166,7 +169,7 @@ public class BoxAnswer { public Builder payload(ContextKey key, T value) { if (checkNotNull(value)) { - payload.put(key, value); + payload.put(key.getValue(), value); } return this; }