From 0c55d254b9cd2909d3356e49c5d5547c6e1131fb Mon Sep 17 00:00:00 2001 From: Eunsol Kim <61370551+Cyma-s@users.noreply.github.com> Date: Sat, 4 Nov 2023 17:04:23 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=B6=84=EA=B8=B0=EB=AC=B8=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shook/song/domain/InMemorySongs.java | 31 ++----------------- 1 file changed, 2 insertions(+), 29 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 e233f96a..a3783b7a 100644 --- a/backend/src/main/java/shook/shook/song/domain/InMemorySongs.java +++ b/backend/src/main/java/shook/shook/song/domain/InMemorySongs.java @@ -132,35 +132,8 @@ private void reorder(final Song updatedSong) { return; } - if (shouldMoveForward(updatedSong, currentSongIndex)) { - moveForward(updatedSong, currentSongIndex); - } - - if (shouldMoveBackward(updatedSong, currentSongIndex)) { - moveBackward(updatedSong, currentSongIndex); - } - } - - private boolean shouldMoveForward(final Song song, final int index) { - if (index <= 0) { - return false; - } - - final Long prevSongId = sortedSongIds.get(index - 1); - final Song prevSong = songs.get(prevSongId); - - return shouldSwapWithPrevious(song, prevSong); - } - - private boolean shouldMoveBackward(final Song song, final int index) { - if (index >= sortedSongIds.size() - 1) { - return false; - } - - final Long nextSongId = sortedSongIds.get(index + 1); - final Song nextSong = songs.get(nextSongId); - - return shouldSwapWithNext(song, nextSong); + moveForward(updatedSong, currentSongIndex); + moveBackward(updatedSong, currentSongIndex); } private void moveForward(final Song changedSong, final int songIndex) {