Change name to id on AccountBadge

This makes it distinct from the localized name field on the Badge
entity that is returned.
This commit is contained in:
Ehren Kret 2021-09-15 16:44:42 -05:00
parent 98a31d1474
commit 34e21b9f7b
3 changed files with 13 additions and 13 deletions

View File

@ -89,10 +89,10 @@ public class ConfiguredProfileBadgeConverter implements ProfileBadgeConverter {
return accountBadges.stream() return accountBadges.stream()
.filter(accountBadge -> accountBadge.isVisible() .filter(accountBadge -> accountBadge.isVisible()
&& now.isBefore(accountBadge.getExpiration()) && now.isBefore(accountBadge.getExpiration())
&& knownBadges.containsKey(accountBadge.getName())) && knownBadges.containsKey(accountBadge.getId()))
.map(accountBadge -> new Badge(knownBadges.get(accountBadge.getName()).getImageUrl(), .map(accountBadge -> new Badge(knownBadges.get(accountBadge.getId()).getImageUrl(),
resourceBundle.getString(accountBadge.getName() + "_name"), resourceBundle.getString(accountBadge.getId() + "_name"),
resourceBundle.getString(accountBadge.getName() + "_description"))) resourceBundle.getString(accountBadge.getId() + "_description")))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
} }

View File

@ -331,7 +331,7 @@ public class Account {
public void removeBadge(String name) { public void removeBadge(String name) {
requireNotStale(); requireNotStale();
badges.removeIf(accountBadge -> Objects.equals(accountBadge.getName(), name)); badges.removeIf(accountBadge -> Objects.equals(accountBadge.getId(), name));
purgeStaleBadges(); purgeStaleBadges();
} }

View File

@ -12,22 +12,22 @@ import java.util.Objects;
public class AccountBadge { public class AccountBadge {
private final String name; private final String id;
private final Instant expiration; private final Instant expiration;
private final boolean visible; private final boolean visible;
@JsonCreator @JsonCreator
public AccountBadge( public AccountBadge(
@JsonProperty("name") String name, @JsonProperty("id") String id,
@JsonProperty("expiration") Instant expiration, @JsonProperty("expiration") Instant expiration,
@JsonProperty("visible") boolean visible) { @JsonProperty("visible") boolean visible) {
this.name = name; this.id = id;
this.expiration = expiration; this.expiration = expiration;
this.visible = visible; this.visible = visible;
} }
public String getName() { public String getId() {
return name; return id;
} }
public Instant getExpiration() { public Instant getExpiration() {
@ -47,19 +47,19 @@ public class AccountBadge {
return false; return false;
} }
AccountBadge that = (AccountBadge) o; AccountBadge that = (AccountBadge) o;
return visible == that.visible && Objects.equals(name, that.name) return visible == that.visible && Objects.equals(id, that.id)
&& Objects.equals(expiration, that.expiration); && Objects.equals(expiration, that.expiration);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(name, expiration, visible); return Objects.hash(id, expiration, visible);
} }
@Override @Override
public String toString() { public String toString() {
return "AccountBadge{" + return "AccountBadge{" +
"name='" + name + '\'' + "id='" + id + '\'' +
", expiration=" + expiration + ", expiration=" + expiration +
", visible=" + visible + ", visible=" + visible +
'}'; '}';