From ea345c45e4420c0abfc2b80cdeb400c9005583f4 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:29:50 +0900 Subject: [PATCH] =?UTF-8?q?StreamAPI=E3=81=A7=E6=9B=B8=E3=81=8D=E7=9B=B4?= =?UTF-8?q?=E3=81=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/LacertaApplyTagDialog.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index 51439f9a..c8709a20 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; +import java.util.stream.Collectors; import javax.inject.Inject; @@ -147,17 +148,14 @@ public class LacertaApplyTagDialog extends DialogFragment { logger.debug("getDocumentTagArrayList", "this.registeredTags.size(): " + this.registeredTags.size()); logger.debug("getDocumentTagArrayList", "this.appliedTags.size(): " + this.appliedTags.size()); - for (int i = 0; i < this.registeredTags.size(); i++) { - boolean isChecked = false; - for (int j = 0; j < this.appliedTags.size(); j++) { - if (this.registeredTags.get(i).getId().equals(this.appliedTags.get(j).getId())) { - isChecked = true; - break; - } - } - documentTagArrayList.add(new DocumentTagApplyTagDialogExtendedModel( - new DocumentTag(this.registeredTags.get(i).getId(), this.registeredTags.get(i).getName(), this.registeredTags.get(i).getColor()), isChecked)); - } + documentTagArrayList.addAll(this.registeredTags.stream().map(tag -> { + DocumentTagApplyTagDialogExtendedModel documentTag = new DocumentTagApplyTagDialogExtendedModel( + new DocumentTag(tag.getId(), tag.getName(), tag.getColor()), + this.appliedTags.stream().anyMatch(appliedTag -> appliedTag.getId().equals(tag.getId())) + ); + return documentTag; + }).collect(Collectors.toCollection(ArrayList::new))); + }).join(); return documentTagArrayList; });