package com.adins.mss.dao;

import android.database.Cursor;

import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;
import de.greenrobot.dao.database.Database;
import de.greenrobot.dao.database.DatabaseStatement;

import com.adins.mss.dao.BankAccountOfBranch;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "MS_BANKACCOUNTOFBRANCH".
*/
public class BankAccountOfBranchDao extends AbstractDao<BankAccountOfBranch, String> {

    public static final String TABLENAME = "MS_BANKACCOUNTOFBRANCH";

    /**
     * Properties of entity BankAccountOfBranch.<br/>
     * Can be used for QueryBuilder and for referencing column names.
    */
    public static class Properties {
        public final static Property Uuid_bankaccountofbranch = new Property(0, String.class, "uuid_bankaccountofbranch", true, "UUID_BANKACCOUNTOFBRANCH");
        public final static Property Bank_account_id = new Property(1, String.class, "bank_account_id", false, "BANK_ACCOUNT_ID");
        public final static Property Bank_account_no = new Property(2, String.class, "bank_account_no", false, "BANK_ACCOUNT_NO");
        public final static Property Bank_account_name = new Property(3, String.class, "bank_account_name", false, "BANK_ACCOUNT_NAME");
        public final static Property Branch_code = new Property(4, String.class, "branch_code", false, "BRANCH_CODE");
    };


    public BankAccountOfBranchDao(DaoConfig config) {
        super(config);
    }
    
    public BankAccountOfBranchDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"MS_BANKACCOUNTOFBRANCH\" (" + //
                "\"UUID_BANKACCOUNTOFBRANCH\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid_bankaccountofbranch
                "\"BANK_ACCOUNT_ID\" TEXT," + // 1: bank_account_id
                "\"BANK_ACCOUNT_NO\" TEXT," + // 2: bank_account_no
                "\"BANK_ACCOUNT_NAME\" TEXT," + // 3: bank_account_name
                "\"BRANCH_CODE\" TEXT);"); // 4: branch_code
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MS_BANKACCOUNTOFBRANCH\"";
        db.execSQL(sql);
    }

    /** @inheritdoc */
    @Override
    protected void bindValues(DatabaseStatement stmt, BankAccountOfBranch entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getUuid_bankaccountofbranch());
 
        String bank_account_id = entity.getBank_account_id();
        if (bank_account_id != null) {
            stmt.bindString(2, bank_account_id);
        }
 
        String bank_account_no = entity.getBank_account_no();
        if (bank_account_no != null) {
            stmt.bindString(3, bank_account_no);
        }
 
        String bank_account_name = entity.getBank_account_name();
        if (bank_account_name != null) {
            stmt.bindString(4, bank_account_name);
        }
 
        String branch_code = entity.getBranch_code();
        if (branch_code != null) {
            stmt.bindString(5, branch_code);
        }
    }

    /** @inheritdoc */
    @Override
    public String readKey(Cursor cursor, int offset) {
        return cursor.getString(offset + 0);
    }    

    /** @inheritdoc */
    @Override
    public BankAccountOfBranch readEntity(Cursor cursor, int offset) {
        BankAccountOfBranch entity = new BankAccountOfBranch( //
            cursor.getString(offset + 0), // uuid_bankaccountofbranch
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // bank_account_id
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // bank_account_no
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // bank_account_name
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4) // branch_code
        );
        return entity;
    }
     
    /** @inheritdoc */
    @Override
    public void readEntity(Cursor cursor, BankAccountOfBranch entity, int offset) {
        entity.setUuid_bankaccountofbranch(cursor.getString(offset + 0));
        entity.setBank_account_id(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setBank_account_no(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setBank_account_name(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setBranch_code(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
     }
    
    /** @inheritdoc */
    @Override
    protected String updateKeyAfterInsert(BankAccountOfBranch entity, long rowId) {
        return entity.getUuid_bankaccountofbranch();
    }
    
    /** @inheritdoc */
    @Override
    public String getKey(BankAccountOfBranch entity) {
        if(entity != null) {
            return entity.getUuid_bankaccountofbranch();
        } else {
            return null;
        }
    }

    /** @inheritdoc */
    @Override    
    protected boolean isEntityUpdateable() {
        return true;
    }
    
}
