Skip to content

Commit

Permalink
Provide AuthAccount in AccountLinkAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
bivashy committed Nov 2, 2023
1 parent a142f5d commit 62fc881
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import com.bivashy.auth.api.link.user.LinkUser;

import me.mastercapexd.auth.database.model.AccountLink;
import me.mastercapexd.auth.database.model.AuthAccount;

public class AccountLinkAdapter extends AccountLink {

public AccountLinkAdapter(LinkUser linkUser) {
public AccountLinkAdapter(LinkUser linkUser, AuthAccount account) {
super(linkUser.getLinkType().getName(), linkUser.getLinkUserInfo().getIdentificator().asString(), linkUser.getLinkUserInfo().isConfirmationEnabled(),
null);
account);
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package me.mastercapexd.auth.database.model;

import java.util.Objects;

import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

@DatabaseTable(tableName = "auth_links")
public class AccountLink {

public static final String LINK_TYPE_FIELD_KEY = "link_type";
public static final String LINK_USER_ID_FIELD_KEY = "link_user_id";
public static final String LINK_ENABLED_FIELD_KEY = "link_enabled";
Expand Down Expand Up @@ -43,6 +46,10 @@ public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getLinkType() {
return linkType;
}
Expand All @@ -59,11 +66,20 @@ public AuthAccount getAccount() {
return account;
}

public void setLinkUserId(String linkUserId) {
this.linkUserId = linkUserId;
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof AccountLink))
return false;
AccountLink that = (AccountLink) o;
return getId() == that.getId() && isLinkEnabled() == that.isLinkEnabled() && Objects.equals(getLinkType(), that.getLinkType()) &&
Objects.equals(getLinkUserId(), that.getLinkUserId()) && getAccount().getId() == that.getAccount().getId();
}

public void setLinkEnabled(boolean linkEnabled) {
this.linkEnabled = linkEnabled;
@Override
public int hashCode() {
return Objects.hash(getId(), getLinkType(), getLinkUserId(), isLinkEnabled(), getAccount().getId());
}

}

0 comments on commit 62fc881

Please sign in to comment.