Skip to content

Instantly share code, notes, and snippets.

@YousufSohail
Created April 4, 2018 09:03
Show Gist options
  • Save YousufSohail/3d8267379b15fd34968445fda606175c to your computer and use it in GitHub Desktop.
Save YousufSohail/3d8267379b15fd34968445fda606175c to your computer and use it in GitHub Desktop.
Use Dao inheritance to reduce the amount of boilerplate code
package com.folio3.dotnline.common.data.source.local
import android.arch.persistence.room.Delete
import android.arch.persistence.room.Insert
import android.arch.persistence.room.Update
/**
* Created by Yousuf Sohail on 4/4/18.
*/
interface BaseDao<T> {
/**
* Insert an object in the database.
*
* @param obj the object to be inserted.
*/
@Insert
fun insert(obj: T)
/**
* Insert an array of objects in the database.
*
* @param obj the objects to be inserted.
*/
@Insert
fun insert(vararg obj: T)
/**
* Update an object from the database.
*
* @param obj the object to be updated
*/
@Update
fun update(obj: T)
/**
* Delete an object from the database
*
* @param obj the object to be deleted
*/
@Delete
fun delete(obj: T)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment