crystal-wallet-android/app/src/main/java/cy/agorise/crystalwallet/models/CryptoNetBalance.java

78 lines
2.1 KiB
Java
Raw Normal View History

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;
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;
import cy.agorise.crystalwallet.enums.CryptoNet;
import static android.arch.persistence.room.ColumnInfo.INTEGER;
2017-10-12 02:08:42 +00:00
/**
* Represents a generic CryptoNet Account Balance
2017-10-12 02:08:42 +00:00
*
* Created by Henry Varona on 6/9/2017.
*/
@Entity
2017-10-12 02:08:42 +00:00
public class CryptoNetBalance {
/**
* The id of the account of this balance
2017-10-12 02:08:42 +00:00
*/
@ColumnInfo(name = "account_id")
private long mAccountId;
2017-10-12 02:08:42 +00:00
/**
* The cryptonet of the account
2017-10-12 02:08:42 +00:00
*/
@ColumnInfo(name = "account_number", typeAffinity = INTEGER)
private CryptoNet mCryptoNet;
2017-10-12 02:08:42 +00:00
public long getAccountId() {
return mAccountId;
2017-10-12 02:08:42 +00:00
}
public CryptoNet getCryptoNet() {
return mCryptoNet;
2017-10-12 02:08:42 +00:00
}
public void setAccountId(long accountId) {
this.mAccountId = accountId;
2017-10-12 02:08:42 +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) {
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;
return mAccountId == that.mAccountId;
2017-10-12 02:08:42 +00:00
}
}