From a3c4a10721f4edb99d316dcc1e53b8047207d355 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 20 Jan 2021 06:29:50 +0530 Subject: [PATCH] Convert the abstract class DAOs to interfaces. --- .../database/playlist/dao/PlaylistDAO.java | 14 +++++++------- .../database/playlist/dao/PlaylistRemoteDAO.java | 16 ++++++++-------- .../database/playlist/dao/PlaylistStreamDAO.java | 16 ++++++++-------- .../database/stream/dao/StreamStateDAO.java | 16 ++++++++-------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistDAO.java b/app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistDAO.java index 078385e56..70aaa3b2d 100644 --- a/app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistDAO.java +++ b/app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistDAO.java @@ -14,26 +14,26 @@ import static org.schabi.newpipe.database.playlist.model.PlaylistEntity.PLAYLIST import static org.schabi.newpipe.database.playlist.model.PlaylistEntity.PLAYLIST_TABLE; @Dao -public abstract class PlaylistDAO implements BasicDAO { +public interface PlaylistDAO extends BasicDAO { @Override @Query("SELECT * FROM " + PLAYLIST_TABLE) - public abstract Flowable> getAll(); + Flowable> getAll(); @Override @Query("DELETE FROM " + PLAYLIST_TABLE) - public abstract int deleteAll(); + int deleteAll(); @Override - public Flowable> listByService(final int serviceId) { + default Flowable> listByService(final int serviceId) { throw new UnsupportedOperationException(); } @Query("SELECT * FROM " + PLAYLIST_TABLE + " WHERE " + PLAYLIST_ID + " = :playlistId") - public abstract Flowable> getPlaylist(long playlistId); + Flowable> getPlaylist(long playlistId); @Query("DELETE FROM " + PLAYLIST_TABLE + " WHERE " + PLAYLIST_ID + " = :playlistId") - public abstract int deletePlaylist(long playlistId); + int deletePlaylist(long playlistId); @Query("SELECT COUNT(*) FROM " + PLAYLIST_TABLE) - public abstract Flowable getCount(); + Flowable getCount(); } diff --git a/app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistRemoteDAO.java b/app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistRemoteDAO.java index a488f00fc..6bb849428 100644 --- a/app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistRemoteDAO.java +++ b/app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistRemoteDAO.java @@ -17,31 +17,31 @@ import static org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity.RE import static org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity.REMOTE_PLAYLIST_URL; @Dao -public abstract class PlaylistRemoteDAO implements BasicDAO { +public interface PlaylistRemoteDAO extends BasicDAO { @Override @Query("SELECT * FROM " + REMOTE_PLAYLIST_TABLE) - public abstract Flowable> getAll(); + Flowable> getAll(); @Override @Query("DELETE FROM " + REMOTE_PLAYLIST_TABLE) - public abstract int deleteAll(); + int deleteAll(); @Override @Query("SELECT * FROM " + REMOTE_PLAYLIST_TABLE + " WHERE " + REMOTE_PLAYLIST_SERVICE_ID + " = :serviceId") - public abstract Flowable> listByService(int serviceId); + Flowable> listByService(int serviceId); @Query("SELECT * FROM " + REMOTE_PLAYLIST_TABLE + " WHERE " + REMOTE_PLAYLIST_URL + " = :url AND " + REMOTE_PLAYLIST_SERVICE_ID + " = :serviceId") - public abstract Flowable> getPlaylist(long serviceId, String url); + Flowable> getPlaylist(long serviceId, String url); @Query("SELECT " + REMOTE_PLAYLIST_ID + " FROM " + REMOTE_PLAYLIST_TABLE + " WHERE " + REMOTE_PLAYLIST_URL + " = :url " + "AND " + REMOTE_PLAYLIST_SERVICE_ID + " = :serviceId") - abstract Long getPlaylistIdInternal(long serviceId, String url); + Long getPlaylistIdInternal(long serviceId, String url); @Transaction - public long upsert(final PlaylistRemoteEntity playlist) { + default long upsert(final PlaylistRemoteEntity playlist) { final Long playlistId = getPlaylistIdInternal(playlist.getServiceId(), playlist.getUrl()); if (playlistId == null) { @@ -55,5 +55,5 @@ public abstract class PlaylistRemoteDAO implements BasicDAO { +public interface PlaylistStreamDAO extends BasicDAO { @Override @Query("SELECT * FROM " + PLAYLIST_STREAM_JOIN_TABLE) - public abstract Flowable> getAll(); + Flowable> getAll(); @Override @Query("DELETE FROM " + PLAYLIST_STREAM_JOIN_TABLE) - public abstract int deleteAll(); + int deleteAll(); @Override - public Flowable> listByService(final int serviceId) { + default Flowable> listByService(final int serviceId) { throw new UnsupportedOperationException(); } @Query("DELETE FROM " + PLAYLIST_STREAM_JOIN_TABLE + " WHERE " + JOIN_PLAYLIST_ID + " = :playlistId") - public abstract void deleteBatch(long playlistId); + void deleteBatch(long playlistId); @Query("SELECT COALESCE(MAX(" + JOIN_INDEX + "), -1)" + " FROM " + PLAYLIST_STREAM_JOIN_TABLE + " WHERE " + JOIN_PLAYLIST_ID + " = :playlistId") - public abstract Flowable getMaximumIndexOf(long playlistId); + Flowable getMaximumIndexOf(long playlistId); @Transaction @Query("SELECT * FROM " + STREAM_TABLE + " INNER JOIN " @@ -69,7 +69,7 @@ public abstract class PlaylistStreamDAO implements BasicDAO> getOrderedStreamsOf(long playlistId); + Flowable> getOrderedStreamsOf(long playlistId); @Transaction @Query("SELECT " + PLAYLIST_ID + ", " + PLAYLIST_NAME + ", " + PLAYLIST_THUMBNAIL_URL + ", " @@ -80,5 +80,5 @@ public abstract class PlaylistStreamDAO implements BasicDAO> getPlaylistMetadata(); + Flowable> getPlaylistMetadata(); } diff --git a/app/src/main/java/org/schabi/newpipe/database/stream/dao/StreamStateDAO.java b/app/src/main/java/org/schabi/newpipe/database/stream/dao/StreamStateDAO.java index a6b36e3ff..06371248d 100644 --- a/app/src/main/java/org/schabi/newpipe/database/stream/dao/StreamStateDAO.java +++ b/app/src/main/java/org/schabi/newpipe/database/stream/dao/StreamStateDAO.java @@ -17,31 +17,31 @@ import static org.schabi.newpipe.database.stream.model.StreamStateEntity.JOIN_ST import static org.schabi.newpipe.database.stream.model.StreamStateEntity.STREAM_STATE_TABLE; @Dao -public abstract class StreamStateDAO implements BasicDAO { +public interface StreamStateDAO extends BasicDAO { @Override @Query("SELECT * FROM " + STREAM_STATE_TABLE) - public abstract Flowable> getAll(); + Flowable> getAll(); @Override @Query("DELETE FROM " + STREAM_STATE_TABLE) - public abstract int deleteAll(); + int deleteAll(); @Override - public Flowable> listByService(final int serviceId) { + default Flowable> listByService(final int serviceId) { throw new UnsupportedOperationException(); } @Query("SELECT * FROM " + STREAM_STATE_TABLE + " WHERE " + JOIN_STREAM_ID + " = :streamId") - public abstract Flowable> getState(long streamId); + Flowable> getState(long streamId); @Query("DELETE FROM " + STREAM_STATE_TABLE + " WHERE " + JOIN_STREAM_ID + " = :streamId") - public abstract int deleteState(long streamId); + int deleteState(long streamId); @Insert(onConflict = OnConflictStrategy.IGNORE) - abstract void silentInsertInternal(StreamStateEntity streamState); + void silentInsertInternal(StreamStateEntity streamState); @Transaction - public long upsert(final StreamStateEntity stream) { + default long upsert(final StreamStateEntity stream) { silentInsertInternal(stream); return update(stream); }