Add visibility modifying helper method in AccountBadge
This commit is contained in:
parent
3172b571c6
commit
5c1cde1b28
|
@ -484,10 +484,7 @@ public class ProfileController {
|
||||||
|
|
||||||
// reordering or making visible existing badges
|
// reordering or making visible existing badges
|
||||||
if (existingBadges.containsKey(badgeId)) {
|
if (existingBadges.containsKey(badgeId)) {
|
||||||
AccountBadge accountBadge = existingBadges.get(badgeId);
|
AccountBadge accountBadge = existingBadges.get(badgeId).withVisibility(true);
|
||||||
if (!accountBadge.isVisible()) {
|
|
||||||
accountBadge = new AccountBadge(badgeId, accountBadge.getExpiration(), true);
|
|
||||||
}
|
|
||||||
result.put(badgeId, accountBadge);
|
result.put(badgeId, accountBadge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -495,10 +492,7 @@ public class ProfileController {
|
||||||
// take any remaining account badges and make them invisible
|
// take any remaining account badges and make them invisible
|
||||||
for (final Entry<String, AccountBadge> entry : existingBadges.entrySet()) {
|
for (final Entry<String, AccountBadge> entry : existingBadges.entrySet()) {
|
||||||
if (!result.containsKey(entry.getKey())) {
|
if (!result.containsKey(entry.getKey())) {
|
||||||
AccountBadge accountBadge = entry.getValue();
|
AccountBadge accountBadge = entry.getValue().withVisibility(false);
|
||||||
if (accountBadge.isVisible()) {
|
|
||||||
accountBadge = new AccountBadge(accountBadge.getId(), accountBadge.getExpiration(), false);
|
|
||||||
}
|
|
||||||
result.put(accountBadge.getId(), accountBadge);
|
result.put(accountBadge.getId(), accountBadge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,17 @@ public class AccountBadge {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AccountBadge withVisibility(boolean visible) {
|
||||||
|
if (this.visible == visible) {
|
||||||
|
return this;
|
||||||
|
} else {
|
||||||
|
return new AccountBadge(
|
||||||
|
this.id,
|
||||||
|
this.expiration,
|
||||||
|
visible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue