From 16dfccca1443a9ba6406ac4137a07044ce5d3b2e Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:21:59 +0900 Subject: [PATCH] =?UTF-8?q?forEach=E6=96=87=E3=82=92=E3=82=84=E3=82=81?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/vcs/impl/LacertaVcsImpl.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java index 3dda05d7..04a13c59 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java @@ -219,29 +219,30 @@ public class LacertaVcsImpl implements LacertaVcs { logger.debug(TAG, "getDocumentPagePathListRev"); ArrayList vcsLogEntities = getRevBeforeTargetIdAsync(revId).thenCompose(this::getLogInRevsAsync).join(); - // finalで宣言しないとLambda式内で扱えないので - final ArrayList[] fileNameList = new ArrayList[]{new ArrayList<>()}; - - vcsLogEntities.forEach(vcsLogEntity -> { + ArrayList fileNameList = new ArrayList<>(); + for(VcsLogEntity vcsLogEntity : vcsLogEntities){ logger.debug(TAG, "getDocumentPagePathListRev: processing " + vcsLogEntity.id + "(Type: " + vcsLogEntity.actionType + ")"); if (vcsLogEntity.actionType.equals(ActionType.INSERT_PAGE.getValue())){ InsertPage insertPage = (InsertPage) JsonUtils.fromJson(vcsLogEntity.action, ActionType.INSERT_PAGE); - fileNameList[0].add(insertPage.getIndex(), insertPage.getFileName()); + logger.debug(TAG, "getDocumentPagePathListRev: Inserting " + insertPage.getFileName() + " at " + insertPage.getIndex()); + fileNameList.add(insertPage.getIndex(), insertPage.getFileName()); } else if (vcsLogEntity.actionType.equals(ActionType.UPDATE_PAGE.getValue())){ UpdatePage updatePage = (UpdatePage) JsonUtils.fromJson(vcsLogEntity.action, ActionType.UPDATE_PAGE); - fileNameList[0].set(updatePage.getIndex(), updatePage.getFileName()); + logger.debug(TAG, "getDocumentPagePathListRev: Updating " + updatePage.getFileName() + " at " + updatePage.getIndex()); + fileNameList.set(updatePage.getIndex(), updatePage.getFileName()); } else if (vcsLogEntity.actionType.equals(ActionType.DELETE_PAGE.getValue())){ DeletePage deletePage = (DeletePage) JsonUtils.fromJson(vcsLogEntity.action, ActionType.DELETE_PAGE); - fileNameList[0].remove(deletePage.getIndex()); + logger.debug(TAG, "getDocumentPagePathListRev: Deleting " + deletePage.getIndex()); + fileNameList.remove(deletePage.getIndex()); } else if (vcsLogEntity.actionType.equals(ActionType.CREATE_DOCUMENT.getValue())) { // Ignore logger.debug(TAG, "getDocumentPagePathListRev: Ignored action type: " + vcsLogEntity.actionType); } else { logger.error(TAG, "getDocumentPagePathListRev: Unknown action type"); } - }); + } - return fileNameList[0]; + return fileNameList; }); }