Files
FairEmail/app/src/main/java/eu/faircode/email/EntityIdentity.java

90 lines
2.7 KiB
Java
Raw Normal View History

2018-08-02 13:33:06 +00:00
package eu.faircode.email;
/*
This file is part of Safe email.
Safe email is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
NetGuard is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with NetGuard. If not, see <http://www.gnu.org/licenses/>.
Copyright 2018 by Marcel Bokhorst (M66B)
*/
2018-08-08 06:55:47 +00:00
import androidx.annotation.NonNull;
import androidx.room.Entity;
2018-08-08 10:22:12 +00:00
import androidx.room.ForeignKey;
import androidx.room.Index;
2018-08-08 06:55:47 +00:00
import androidx.room.PrimaryKey;
2018-08-02 13:33:06 +00:00
2018-08-08 10:22:12 +00:00
import static androidx.room.ForeignKey.CASCADE;
2018-08-02 13:33:06 +00:00
@Entity(
tableName = EntityIdentity.TABLE_NAME,
2018-08-08 10:22:12 +00:00
foreignKeys = {
@ForeignKey(childColumns = "account", entity = EntityAccount.class, parentColumns = "id", onDelete = CASCADE)
},
2018-08-02 13:33:06 +00:00
indices = {
2018-08-08 10:22:12 +00:00
@Index(value = {"account"})
2018-08-02 13:33:06 +00:00
}
)
public class EntityIdentity {
static final String TABLE_NAME = "identity";
@PrimaryKey(autoGenerate = true)
public Long id;
@NonNull
public String name;
@NonNull
public String email;
public String replyto;
@NonNull
2018-08-08 10:22:12 +00:00
public Long account;
@NonNull
2018-08-02 13:33:06 +00:00
public String host; // SMTP
@NonNull
public Integer port;
@NonNull
public Boolean starttls;
@NonNull
public String user;
@NonNull
public String password;
@NonNull
public Boolean primary;
@NonNull
public Boolean synchronize;
@Override
public boolean equals(Object obj) {
if (obj instanceof EntityIdentity) {
EntityIdentity other = (EntityIdentity) obj;
return (this.name.equals(other.name) &&
this.email.equals(other.email) &&
2018-08-04 19:54:33 +00:00
(this.replyto == null ? other.replyto == null : this.replyto.equals(other.replyto)) &&
2018-08-08 10:22:12 +00:00
this.account.equals(other.account) &&
2018-08-02 13:33:06 +00:00
this.host.equals(other.host) &&
this.port.equals(other.port) &&
this.starttls.equals(other.starttls) &&
this.user.equals(other.user) &&
this.password.equals(other.password) &&
this.primary.equals(other.primary) &&
this.synchronize.equals(other.synchronize));
} else
return false;
}
@Override
public String toString() {
2018-08-06 09:50:53 +00:00
return name + (primary ? "" : "");
2018-08-02 13:33:06 +00:00
}
}