2017-09-08 00:31:38 +00:00
|
|
|
package cy.agorise.crystalwallet.models;
|
|
|
|
|
2017-09-13 21:52:36 +00:00
|
|
|
|
|
|
|
import android.arch.persistence.room.ColumnInfo;
|
|
|
|
import android.arch.persistence.room.Entity;
|
|
|
|
import android.arch.persistence.room.PrimaryKey;
|
2017-10-01 01:52:34 +00:00
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
import android.support.v7.recyclerview.extensions.DiffCallback;
|
|
|
|
|
|
|
|
import cy.agorise.crystalwallet.enums.SeedType;
|
2017-09-08 00:31:38 +00:00
|
|
|
|
|
|
|
/**
|
2017-09-13 21:52:36 +00:00
|
|
|
* Represents a type of crypto seed for HD wallets
|
|
|
|
*
|
2017-09-08 00:31:38 +00:00
|
|
|
* Created by Henry Varona on 6/9/2017.
|
|
|
|
*/
|
2017-09-10 23:13:32 +00:00
|
|
|
@Entity(tableName = "account_seed")
|
2017-09-08 00:31:38 +00:00
|
|
|
public class AccountSeed {
|
|
|
|
|
2017-09-13 21:52:36 +00:00
|
|
|
/**
|
|
|
|
* The id on the database
|
|
|
|
*/
|
2017-09-08 00:31:38 +00:00
|
|
|
@PrimaryKey(autoGenerate = true)
|
|
|
|
@ColumnInfo(name = "id")
|
2017-09-27 02:24:23 +00:00
|
|
|
private long mId;
|
2017-09-08 00:31:38 +00:00
|
|
|
|
2017-09-13 21:52:36 +00:00
|
|
|
/**
|
|
|
|
* The name or tag of this seed
|
|
|
|
*/
|
2017-09-08 00:31:38 +00:00
|
|
|
@ColumnInfo(name = "name")
|
|
|
|
private String mName;
|
|
|
|
|
2017-09-13 21:52:36 +00:00
|
|
|
/**
|
|
|
|
* The bytes of the master seed
|
|
|
|
*/
|
2017-09-08 00:31:38 +00:00
|
|
|
@ColumnInfo(name = "master_seed")
|
|
|
|
private String mMasterSeed;
|
|
|
|
|
2017-10-01 01:52:34 +00:00
|
|
|
/**
|
|
|
|
* The type of this seed: BIP39, BRAINKEY
|
|
|
|
*/
|
|
|
|
private SeedType type;
|
|
|
|
|
2017-09-27 02:24:23 +00:00
|
|
|
public long getId() {
|
2017-09-08 00:31:38 +00:00
|
|
|
return mId;
|
|
|
|
}
|
|
|
|
|
2017-09-27 02:24:23 +00:00
|
|
|
public void setId(long id){
|
2017-09-08 00:31:38 +00:00
|
|
|
this.mId = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
return mName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setName(String mName) {
|
|
|
|
this.mName = mName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getMasterSeed() {
|
|
|
|
return mMasterSeed;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMasterSeed(String mMasterSeed) {
|
|
|
|
this.mMasterSeed = mMasterSeed;
|
|
|
|
}
|
|
|
|
|
2017-10-01 01:52:34 +00:00
|
|
|
public SeedType getType() {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setType(SeedType type) {
|
|
|
|
this.type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final DiffCallback<AccountSeed> DIFF_CALLBACK = new DiffCallback<AccountSeed>() {
|
|
|
|
@Override
|
|
|
|
public boolean areItemsTheSame(
|
|
|
|
@NonNull AccountSeed oldAccountSeed, @NonNull AccountSeed newAccountSeed) {
|
|
|
|
return oldAccountSeed.getId() == newAccountSeed.getId();
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public boolean areContentsTheSame(
|
|
|
|
@NonNull AccountSeed oldAccountSeed, @NonNull AccountSeed newAccountSeed) {
|
|
|
|
return oldAccountSeed.equals(newAccountSeed);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object o) {
|
|
|
|
if (this == o) return true;
|
|
|
|
if (o == null || getClass() != o.getClass()) return false;
|
2017-09-08 00:31:38 +00:00
|
|
|
|
2017-10-01 01:52:34 +00:00
|
|
|
AccountSeed that = (AccountSeed) o;
|
|
|
|
|
|
|
|
if (mId != that.mId) return false;
|
|
|
|
return mMasterSeed.equals(that.mMasterSeed);
|
|
|
|
|
|
|
|
}
|
2017-09-08 00:31:38 +00:00
|
|
|
}
|