From 779ec0bbe96a74b2addfbe6b42db982c469ceec9 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Fri, 7 Apr 2023 10:11:58 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B1=D0=B0=D0=B3=20=D0=B2=20ButtonClickAttachment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/attachment/ButtonClickAttachment.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java index f66e453..a8e904f 100644 --- a/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java +++ b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java @@ -1,5 +1,6 @@ package dev.struchkov.godfather.telegram.domain.attachment; +import com.fasterxml.jackson.annotation.JsonIgnore; import dev.struchkov.godfather.main.domain.content.Attachment; import lombok.Getter; import lombok.Setter; @@ -21,29 +22,34 @@ public class ButtonClickAttachment extends Attachment { */ private String messageId; private String rawCallBackData; + private Map args = new HashMap<>(); public ButtonClickAttachment() { super(TelegramAttachmentType.BUTTON_CLICK.name()); } + @JsonIgnore public void addClickArg(String type, String value) { isNotNull(type, value); args.put(type, ButtonArg.buttonArg(type, value)); } + @JsonIgnore public Optional getArgByType(String type) { isNotNull(type); return Optional.ofNullable(args.get(type)); } + @JsonIgnore + public Collection getClickArgs() { + return args.values(); + } + + @JsonIgnore public ButtonArg getArgByTypeOrThrow(String type) { isNotNull(type); return Optional.of(args.get(type)).orElseThrow(notFoundException("Аргумент типа {0} не найден.", type)); } - public Collection getClickArgs() { - return args.values(); - } - }