From 3344b92dea210fc63ee1316ac420493bc973c2fb Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Mon, 20 Mar 2023 17:09:27 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3=20=D1=81=D1=83=D1=89=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B5=D0=B9=20=D1=81=20payload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../godfather/main/domain/content/Mail.java | 30 ++----------------- .../main/domain/content/Message.java | 12 +++----- .../godfather/quarkus/domain/BoxAnswer.java | 17 ++++++----- 3 files changed, 16 insertions(+), 43 deletions(-) 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; }