From 1308b865678b25dcca198370bba281848c071874 Mon Sep 17 00:00:00 2001 From: kohlerpop1 Date: Sat, 23 Dec 2023 20:39:59 -0500 Subject: [PATCH] Made User#attributes final as its only set once and moved each constructor assignment to field declaration! --- .../jwdeveloper/tiktok/data/models/users/User.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/API/src/main/java/io/github/jwdeveloper/tiktok/data/models/users/User.java b/API/src/main/java/io/github/jwdeveloper/tiktok/data/models/users/User.java index 21d95d4..8916799 100644 --- a/API/src/main/java/io/github/jwdeveloper/tiktok/data/models/users/User.java +++ b/API/src/main/java/io/github/jwdeveloper/tiktok/data/models/users/User.java @@ -43,13 +43,12 @@ public class User { private long followers; private List badges; @Getter(AccessLevel.NONE) - private Set attributes; - - + private final Set attributes = new HashSet<>(); public List 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())); } -} +} \ No newline at end of file