// Path: RxDbFlow-Rx2/src/main/java/au/com/roadhouse/rxdbflow/rx2/sql/language/NullValue.java
// public class NullValue {
// }
// 
// Path: RxDbFlow-Rx2/src/main/java/au/com/roadhouse/rxdbflow/rx2/structure/RxBaseModel.java
// @SuppressWarnings("unchecked")
// public class RxBaseModel<M extends RxBaseModel> extends BaseModel implements RxModifications<M> {
// 
//     private transient RxModelAdapter<? extends RxBaseModel> mModelAdapter;
// 
//     /**
//      * Returns an Single for saving the object in the database
//      * @return An Single
//      */
//     public Single<M> saveAsSingle(){
//         return getRxModelAdapter().saveAsSingle(this);
//     }
// 
//     /**
//      * Returns an Single for saving the object in the database
//      * @param databaseWrapper The database wrapper for the database holding the table
//      * @return An Single
//      */
//     @SuppressWarnings("unchecked")
//     public Single<M> saveAsSingle(@Nullable final DatabaseWrapper databaseWrapper){
//         return getRxModelAdapter().saveAsSingle(this, databaseWrapper);
//     }
// 
//     /**
//      * Returns an Single for inserting the object in the database
//      * @return An Single
//      */
//     public Single<M> insertAsSingle(){
//         return getRxModelAdapter().insertAsSingle(this);
//     }
// 
//     /**
//      * Returns an Single for inserting the object in the database
//      * @param databaseWrapper The database wrapper for the database holding the table
//      * @return An Single
//      */
//     public Single<M> insertAsSingle(@Nullable final DatabaseWrapper databaseWrapper){
//         return getRxModelAdapter().insertAsSingle(this, databaseWrapper);
//     }
// 
//     /**
//      * Returns an Single for deleting the object from the database
//      * @return An Single
//      */
//     public Single<M> deleteAsSingle(){
//         return getRxModelAdapter().deleteAsSingle(this);
//     }
// 
//     /**
//      * Returns an Single for deleting the object from the database
//      * @param databaseWrapper The database wrapper for the database holding the table
//      * @return An Single
//      */
//     public Single<M> deleteAsSingle(@Nullable final DatabaseWrapper databaseWrapper){
//         return getRxModelAdapter().deleteAsSingle(this, databaseWrapper);
//     }
// 
//     /**
//      * Returns an Single for update the object in the database
//      * @return An Single
//      */
//     public Single<M> updateAsSingle(){
//         return getRxModelAdapter().updateAsSingle(this);
//     }
// 
//     /**
//      * Returns an Single for update in object from the database
//      * @param databaseWrapper The database wrapper for the database holding the table
//      * @return An Single
//      */
//     public Single<M> updateAsSingle(@Nullable final DatabaseWrapper databaseWrapper){
//         return getRxModelAdapter().updateAsSingle(this, databaseWrapper);
//     }
// 
//     /**
//      * Returns an Single which will refresh the model's data based on the primary key when subscribed.
//      * @return An Single
//      */
//     public Single<M> loadAsSingle(){
//         return getRxModelAdapter().loadAsSingle(this);
//     }
// 
//     /**
//      * Returns an Single which will refresh the model's data based on the primary key when subscribed.
//      * @param databaseWrapper The database wrapper for the database holding the table
//      * @return An Single
//      */
//     public Single<M> loadAsSingle(@Nullable final DatabaseWrapper databaseWrapper){
//         return getRxModelAdapter().loadAsSingle(this, databaseWrapper);
//     }
// 
//     /**
//      * @return The associated {@link RxModelAdapter}. The {@link RxDbFlow}
//      * may throw a {@link InvalidDBConfiguration} for this call if this class
//      * is not associated with a table, so be careful when using this method.
//      */
//     public RxModelAdapter getRxModelAdapter() {
//         if (mModelAdapter == null) {
//             mModelAdapter = RxDbFlow.getModelAdapter(getClass());
//         }
//         return mModelAdapter;
//     }
// }


import android.support.annotation.IntDef;
import com.raizlabs.android.dbflow.config.FlowManager;
import com.raizlabs.android.dbflow.structure.Model;
import com.raizlabs.android.dbflow.structure.ModelAdapter;
import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;
import au.com.roadhouse.rxdbflow.rx2.sql.language.NullValue;
import au.com.roadhouse.rxdbflow.rx2.structure.RxBaseModel;
import io.reactivex.Observable;
import io.reactivex.Observer;
    @IntDef({MODEL_OPERATION_UNSET, MODEL_OPERATION_SAVE, MODEL_OPERATION_UPDATE, MODEL_OPERATION_DELETE, MODEL_OPERATION_INSERT})
    @Retention(RetentionPolicy.SOURCE)
    public @interface ModelOperation {
    }

    public static final int MODEL_OPERATION_UNSET = -1;
    public static final int MODEL_OPERATION_SAVE = 0;
    public static final int MODEL_OPERATION_UPDATE = 1;
    public static final int MODEL_OPERATION_INSERT = 2;
    public static final int MODEL_OPERATION_DELETE = 3;

    private RxModelOperationTransaction(Builder builder) {
        mModelList = builder.mModelList;
        mOperationList = builder.mOperationList;
        mDatabaseWrapper = builder.mDatabaseWrapper;
        mCanBatchTransaction = builder.mCanBatchTransaction;
        mMustUserAdapter = builder.mMustUseAdapters;
    }

    private void performIndividualOperations() {
        for (int i = 0; i < mModelList.size(); i++) {
            @ModelOperation int operation = mOperationList.get(i);
            Model model = (Model) mModelList.get(i);

            if (operation == MODEL_OPERATION_SAVE) {
                model.save();
            } else if (operation == MODEL_OPERATION_DELETE) {
                model.delete();
            } else if (operation == MODEL_OPERATION_INSERT) {
                model.insert();
// Path: RxDbFlow-Rx2/src/main/java/au/com/roadhouse/rxdbflow/rx2/sql/language/NullValue.java
// public class NullValue {
// }
// 
// Path: RxDbFlow-Rx2/src/main/java/au/com/roadhouse/rxdbflow/rx2/structure/RxBaseModel.java
// @SuppressWarnings("unchecked")
// public class RxBaseModel<M extends RxBaseModel> extends BaseModel implements RxModifications<M> {
// 
//     private transient RxModelAdapter<? extends RxBaseModel> mModelAdapter;
// 
//     /**
//      * Returns an Single for saving the object in the database
//      * @return An Single
//      */
//     public Single<M> saveAsSingle(){
//         return getRxModelAdapter().saveAsSingle(this);
//     }
// 
//     /**
//      * Returns an Single for saving the object in the database
//      * @param databaseWrapper The database wrapper for the database holding the table
//      * @return An Single
//      */
//     @SuppressWarnings("unchecked")
//     public Single<M> saveAsSingle(@Nullable final DatabaseWrapper databaseWrapper){
//         return getRxModelAdapter().saveAsSingle(this, databaseWrapper);
//     }
// 
//     /**
//      * Returns an Single for inserting the object in the database
//      * @return An Single
//      */
//     public Single<M> insertAsSingle(){
//         return getRxModelAdapter().insertAsSingle(this);
//     }
// 
//     /**
//      * Returns an Single for inserting the object in the database
//      * @param databaseWrapper The database wrapper for the database holding the table
//      * @return An Single
//      */
//     public Single<M> insertAsSingle(@Nullable final DatabaseWrapper databaseWrapper){
//         return getRxModelAdapter().insertAsSingle(this, databaseWrapper);
//     }
// 
//     /**
//      * Returns an Single for deleting the object from the database
//      * @return An Single
//      */
//     public Single<M> deleteAsSingle(){
//         return getRxModelAdapter().deleteAsSingle(this);
//     }
// 
//     /**
//      * Returns an Single for deleting the object from the database
//      * @param databaseWrapper The database wrapper for the database holding the table
//      * @return An Single
//      */
//     public Single<M> deleteAsSingle(@Nullable final DatabaseWrapper databaseWrapper){
//         return getRxModelAdapter().deleteAsSingle(this, databaseWrapper);
//     }
// 
//     /**
//      * Returns an Single for update the object in the database
//      * @return An Single
//      */
//     public Single<M> updateAsSingle(){
//         return getRxModelAdapter().updateAsSingle(this);
//     }
// 
//     /**
//      * Returns an Single for update in object from the database
//      * @param databaseWrapper The database wrapper for the database holding the table
//      * @return An Single
//      */
//     public Single<M> updateAsSingle(@Nullable final DatabaseWrapper databaseWrapper){
//         return getRxModelAdapter().updateAsSingle(this, databaseWrapper);
//     }
// 
//     /**
//      * Returns an Single which will refresh the model's data based on the primary key when subscribed.
//      * @return An Single
//      */
//     public Single<M> loadAsSingle(){
//         return getRxModelAdapter().loadAsSingle(this);
//     }
// 
//     /**
//      * Returns an Single which will refresh the model's data based on the primary key when subscribed.
//      * @param databaseWrapper The database wrapper for the database holding the table
//      * @return An Single
//      */
//     public Single<M> loadAsSingle(@Nullable final DatabaseWrapper databaseWrapper){
//         return getRxModelAdapter().loadAsSingle(this, databaseWrapper);
//     }
// 
//     /**
//      * @return The associated {@link RxModelAdapter}. The {@link RxDbFlow}
//      * may throw a {@link InvalidDBConfiguration} for this call if this class
//      * is not associated with a table, so be careful when using this method.
//      */
//     public RxModelAdapter getRxModelAdapter() {
//         if (mModelAdapter == null) {
//             mModelAdapter = RxDbFlow.getModelAdapter(getClass());
//         }
//         return mModelAdapter;
//     }
// }


// Path: RxDbFlow-Rx2/src/main/java/au/com/roadhouse/rxdbflow/rx2/sql/transaction/RxModelOperationTransaction.java
import android.support.annotation.IntDef;
import com.raizlabs.android.dbflow.config.FlowManager;
import com.raizlabs.android.dbflow.structure.Model;
import com.raizlabs.android.dbflow.structure.ModelAdapter;
import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;
import au.com.roadhouse.rxdbflow.rx2.sql.language.NullValue;
import au.com.roadhouse.rxdbflow.rx2.structure.RxBaseModel;
import io.reactivex.Observable;
import io.reactivex.Observer;

    @IntDef({MODEL_OPERATION_UNSET, MODEL_OPERATION_SAVE, MODEL_OPERATION_UPDATE, MODEL_OPERATION_DELETE, MODEL_OPERATION_INSERT})
    @Retention(RetentionPolicy.SOURCE)
    public @interface ModelOperation {
    }

    public static final int MODEL_OPERATION_UNSET = -1;
    public static final int MODEL_OPERATION_SAVE = 0;
    public static final int MODEL_OPERATION_UPDATE = 1;
    public static final int MODEL_OPERATION_INSERT = 2;
    public static final int MODEL_OPERATION_DELETE = 3;

    private RxModelOperationTransaction(Builder builder) {
        mModelList = builder.mModelList;
        mOperationList = builder.mOperationList;
        mDatabaseWrapper = builder.mDatabaseWrapper;
        mCanBatchTransaction = builder.mCanBatchTransaction;
        mMustUserAdapter = builder.mMustUseAdapters;
    }

    private void performIndividualOperations() {
        for (int i = 0; i < mModelList.size(); i++) {
            @ModelOperation int operation = mOperationList.get(i);
            Model model = (Model) mModelList.get(i);

            if (operation == MODEL_OPERATION_SAVE) {
                model.save();
            } else if (operation == MODEL_OPERATION_DELETE) {
                model.delete();
            } else if (operation == MODEL_OPERATION_INSERT) {
                model.insert();
            } else if (operation == MODEL_OPERATION_UPDATE) {