Skip to content

Commit 1308b86

Browse files
kohlerpop1jwdeveloper
authored andcommitted
Made User#attributes final as its only set once and moved each constructor assignment to field declaration!
1 parent 20ba88c commit 1308b86

File tree

1 file changed

+3
-7
lines changed
  • API/src/main/java/io/github/jwdeveloper/tiktok/data/models/users

1 file changed

+3
-7
lines changed

API/src/main/java/io/github/jwdeveloper/tiktok/data/models/users/User.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,12 @@ public class User {
4343
private long followers;
4444
private List<Badge> badges;
4545
@Getter(AccessLevel.NONE)
46-
private Set<UserAttribute> attributes;
47-
48-
46+
private final Set<UserAttribute> attributes = new HashSet<>();
4947

5048
public List<UserAttribute> getAttributes() {
5149
return attributes.stream().toList();
5250
}
51+
5352
public boolean hasAttribute(UserAttribute userFlag) {
5453
return attributes.contains(userFlag);
5554
}
@@ -106,7 +105,6 @@ public User(Long userId,
106105
this.following = following;
107106
this.followers = followers;
108107
this.badges = badges;
109-
this.attributes = new HashSet<>();
110108
}
111109

112110
public User(Long id,
@@ -123,14 +121,12 @@ public User(Long id,
123121
this.following = following;
124122
this.followers = followers;
125123
this.badges = badges;
126-
this.attributes = new HashSet<>();
127124
}
128125

129126
public User(Long userId,
130127
String nickName) {
131128
this.id = userId;
132129
this.name = nickName;
133-
this.attributes = new HashSet<>();
134130
}
135131

136132
public User(Long userId,
@@ -213,4 +209,4 @@ public static User map(WebcastEnvelopeMessage.EnvelopeInfo envelopeInfo) {
213209
0,
214210
List.of(Badge.empty()));
215211
}
216-
}
212+
}

0 commit comments

Comments
 (0)