Made User#attributes final as its only set once and moved each constructor assignment to field declaration!

This commit is contained in:
kohlerpop1
2023-12-23 20:39:59 -05:00
committed by Jacek W
parent 20ba88c0ac
commit 1308b86567

View File

@@ -43,13 +43,12 @@ public class User {
private long followers;
private List<Badge> badges;
@Getter(AccessLevel.NONE)
private Set<UserAttribute> attributes;
private final Set<UserAttribute> attributes = new HashSet<>();
public List<UserAttribute> getAttributes() {
return attributes.stream().toList();
}
public boolean hasAttribute(UserAttribute userFlag) {
return attributes.contains(userFlag);
}
@@ -106,7 +105,6 @@ public class User {
this.following = following;
this.followers = followers;
this.badges = badges;
this.attributes = new HashSet<>();
}
public User(Long id,
@@ -123,14 +121,12 @@ public class User {
this.following = following;
this.followers = followers;
this.badges = badges;
this.attributes = new HashSet<>();
}
public User(Long userId,
String nickName) {
this.id = userId;
this.name = nickName;
this.attributes = new HashSet<>();
}
public User(Long userId,
@@ -213,4 +209,4 @@ public class User {
0,
List.of(Badge.empty()));
}
}
}