package com.novoda.downloadmanager;

import android.arch.persistence.room.Database;
import android.arch.persistence.room.Room;
import android.arch.persistence.room.RoomDatabase;
import android.content.Context;

@Database(entities = {RoomBatch.class, RoomFile.class}, version = 1)
abstract class RoomAppDatabase extends RoomDatabase {

    private static volatile RoomAppDatabase singleInstance;
    private static final Object LOCK = new Object();

    abstract RoomBatchDao roomBatchDao();

    abstract RoomFileDao roomFileDao();

    static RoomAppDatabase obtainInstance(Context context) {
        RoomAppDatabase database = singleInstance;
        if (database == null) {
            synchronized (LOCK) {
                database = singleInstance;
                if (database == null) {
                    singleInstance = newInstance(context);
                    database = singleInstance;
                }
            }
        }
        return database;
    }

    static RoomAppDatabase newInstance(Context context) {
        return Room.databaseBuilder(
                context.getApplicationContext(),
                RoomAppDatabase.class,
                "database-litedownloadmanager"
        ).build();
    }

}

@@ -391,61 +391,8 @@
 nce;
-%0A    private static final Object LOCK = new Object();
 %0A%0A  
@@ -546,70 +546,25 @@
     
-RoomAppDatabase database = singleInstance;%0A        if (databas
+if (singleInstanc
 e ==
@@ -602,12 +602,29 @@
 ed (
-LOCK
+RoomAppDatabase.class
 ) %7B%0A
@@ -635,35 +635,28 @@
             
-database = 
+if (
 singleInstan
@@ -661,38 +661,8 @@
 ance
-;%0A                if (database
  == 
@@ -732,55 +732,8 @@
 t);%0A
-                    database = singleInstance;%0A
     
@@ -785,23 +785,29 @@
  return 
-databas
+singleInstanc
 e;%0A    %7D

Simplify RoomAppDatabase synchronized block.