2017-10-12 02:08:42 +00:00
|
|
|
package cy.agorise.crystalwallet.models;
|
|
|
|
|
|
|
|
|
|
|
|
import android.arch.persistence.room.ColumnInfo;
|
|
|
|
import android.arch.persistence.room.Entity;
|
|
|
|
import android.arch.persistence.room.ForeignKey;
|
2017-10-15 02:02:55 +00:00
|
|
|
import android.arch.persistence.room.Ignore;
|
2017-10-12 02:08:42 +00:00
|
|
|
import android.arch.persistence.room.Index;
|
|
|
|
import android.arch.persistence.room.PrimaryKey;
|
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
import android.support.v7.recyclerview.extensions.DiffCallback;
|
|
|
|
|
|
|
|
import cy.agorise.crystalwallet.enums.CryptoCoin;
|
2017-10-15 02:02:55 +00:00
|
|
|
import cy.agorise.crystalwallet.enums.CryptoNet;
|
|
|
|
|
|
|
|
import static android.arch.persistence.room.ColumnInfo.INTEGER;
|
2017-10-12 02:08:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by Henry Varona on 6/9/2017.
|
2017-11-14 02:53:30 +00:00
|
|
|
*
|
|
|
|
* Represents a generic Account Balance from a specific CryptoNet
|
2017-10-12 02:08:42 +00:00
|
|
|
*/
|
|
|
|
|
2017-10-15 02:02:55 +00:00
|
|
|
@Entity
|
2017-10-12 02:08:42 +00:00
|
|
|
public class CryptoNetBalance {
|
|
|
|
|
|
|
|
/**
|
2017-10-15 02:02:55 +00:00
|
|
|
* The id of the account of this balance
|
2017-10-12 02:08:42 +00:00
|
|
|
*/
|
2017-10-15 02:02:55 +00:00
|
|
|
@ColumnInfo(name = "account_id")
|
|
|
|
private long mAccountId;
|
2017-10-12 02:08:42 +00:00
|
|
|
|
|
|
|
/**
|
2017-11-14 02:53:30 +00:00
|
|
|
* The crypto net of the account
|
2017-10-12 02:08:42 +00:00
|
|
|
*/
|
2017-10-18 01:14:37 +00:00
|
|
|
@ColumnInfo(name = "crypto_net")
|
2017-10-15 02:02:55 +00:00
|
|
|
private CryptoNet mCryptoNet;
|
2017-10-12 02:08:42 +00:00
|
|
|
|
2017-10-15 02:02:55 +00:00
|
|
|
public long getAccountId() {
|
|
|
|
return mAccountId;
|
2017-10-12 02:08:42 +00:00
|
|
|
}
|
|
|
|
|
2017-10-15 02:02:55 +00:00
|
|
|
public CryptoNet getCryptoNet() {
|
|
|
|
return mCryptoNet;
|
2017-10-12 02:08:42 +00:00
|
|
|
}
|
|
|
|
|
2017-10-15 02:02:55 +00:00
|
|
|
public void setAccountId(long accountId) {
|
|
|
|
this.mAccountId = accountId;
|
2017-10-12 02:08:42 +00:00
|
|
|
}
|
|
|
|
|
2017-10-15 02:02:55 +00:00
|
|
|
public void setCryptoNet(CryptoNet cryptoNet) {
|
|
|
|
this.mCryptoNet = cryptoNet;
|
2017-10-12 02:08:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final DiffCallback<CryptoNetBalance> DIFF_CALLBACK = new DiffCallback<CryptoNetBalance>() {
|
|
|
|
@Override
|
|
|
|
public boolean areItemsTheSame(
|
|
|
|
@NonNull CryptoNetBalance oldBalance, @NonNull CryptoNetBalance newBalance) {
|
2017-10-15 02:02:55 +00:00
|
|
|
return oldBalance.getAccountId() == newBalance.getAccountId();
|
2017-10-12 02:08:42 +00:00
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public boolean areContentsTheSame(
|
|
|
|
@NonNull CryptoNetBalance oldBalance, @NonNull CryptoNetBalance newBalance) {
|
|
|
|
return oldBalance.equals(newBalance);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object o) {
|
|
|
|
if (this == o) return true;
|
|
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
|
|
|
|
|
|
CryptoNetBalance that = (CryptoNetBalance) o;
|
2017-10-15 02:02:55 +00:00
|
|
|
return mAccountId == that.mAccountId;
|
2017-10-12 02:08:42 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|