From 612179022ca78111660696a2047ed1c049293c83 Mon Sep 17 00:00:00 2001 From: Eunsol Kim <61370551+Cyma-s@users.noreply.github.com> Date: Sat, 4 Nov 2023 17:00:41 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=A4=91=EB=B3=B5=20=EB=B2=94?= =?UTF-8?q?=EC=9C=84=20=EA=B2=80=EC=A6=9D=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/shook/shook/song/domain/InMemorySongs.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/shook/shook/song/domain/InMemorySongs.java b/backend/src/main/java/shook/shook/song/domain/InMemorySongs.java index 3a3da5b8..e233f96a 100644 --- a/backend/src/main/java/shook/shook/song/domain/InMemorySongs.java +++ b/backend/src/main/java/shook/shook/song/domain/InMemorySongs.java @@ -142,25 +142,25 @@ private void reorder(final Song updatedSong) { } private boolean shouldMoveForward(final Song song, final int index) { - if (index == 0) { + if (index <= 0) { return false; } final Long prevSongId = sortedSongIds.get(index - 1); final Song prevSong = songs.get(prevSongId); - return index > 0 && shouldSwapWithPrevious(song, prevSong); + return shouldSwapWithPrevious(song, prevSong); } private boolean shouldMoveBackward(final Song song, final int index) { - if (index == sortedSongIds.size() - 1) { + if (index >= sortedSongIds.size() - 1) { return false; } final Long nextSongId = sortedSongIds.get(index + 1); final Song nextSong = songs.get(nextSongId); - return index < sortedSongIds.size() - 1 && shouldSwapWithNext(song, nextSong); + return shouldSwapWithNext(song, nextSong); } private void moveForward(final Song changedSong, final int songIndex) {