From 4e5aab276adc95d095914e0e34ec69cb82f4904a Mon Sep 17 00:00:00 2001 From: r-ca Date: Sat, 20 Jan 2024 23:17:31 +0900 Subject: [PATCH] =?UTF-8?q?getRecentDocument=E3=82=92=E9=9D=9E=E5=90=8C?= =?UTF-8?q?=E6=9C=9F=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/data/impl/LacertaLibraryImpl.java | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java index 3a182552..086005f8 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java @@ -2,7 +2,9 @@ package one.nem.lacerta.data.impl; import java.text.DateFormat; import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import java.util.concurrent.CompletableFuture; import javax.inject.Inject; @@ -28,23 +30,26 @@ public class LacertaLibraryImpl implements LacertaLibrary { } @Override - public ArrayList getRecentDocument(int limit) { - List documentEntities = database.documentDao().getRecentDocument(limit); + public CompletableFuture> getRecentDocument(int limit) { + return CompletableFuture.supplyAsync(() -> { + List documentEntities = database.documentDao().getRecentDocument(limit); - ArrayList listItems = new ArrayList<>(); - for (DocumentEntity documentEntity : documentEntities) { - ListItem listItem = new ListItem(); - listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT); - listItem.setTitle(documentEntity.title); - listItem.setDescription(DateFormat.getDateInstance().format(documentEntity.updatedAt)); - listItem.setItemId(documentEntity.id); - listItems.add(listItem); - } - return listItems; + ArrayList listItems = new ArrayList<>(); + for (DocumentEntity documentEntity : documentEntities) { + ListItem listItem = new ListItem(); + listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT); + listItem.setTitle(documentEntity.title); + listItem.setDescription(DateFormat.getDateInstance().format(documentEntity.updatedAt)); + listItem.setItemId(documentEntity.id); + listItems.add(listItem); + } + + return listItems; + }); } @Override - public ArrayList getRecentDocument(int limit, int offset) { + public CompletableFuture> getRecentDocument(int limit, int offset) { return null; // TODO-rca: Implement }