From 80cd101bf9291cd9e8b1a883e3148ff95c445cc1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 8 Apr 2016 16:22:07 +0300 Subject: encapsulate some properties --- src/main/java/com/juick/Message.java | 18 +++++++++++++----- src/main/java/com/juick/User.java | 24 ++++++++++++++++++++---- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/juick/Message.java b/src/main/java/com/juick/Message.java index 263a247d..c128b4f2 100644 --- a/src/main/java/com/juick/Message.java +++ b/src/main/java/com/juick/Message.java @@ -47,10 +47,10 @@ public class Message implements Comparable { public String Video = null; public Place Place = null; public int Likes = 0; - public boolean UserLike = false; + private boolean liked = false; public List childs = new ArrayList<>(); private Optional PM = Optional.empty(); - Optional Recommendation = Optional.empty(); + private Optional Recommendation = Optional.empty(); public Message() { } @@ -74,7 +74,7 @@ public class Message implements Comparable { Video = msg.Video; Place = msg.Place; Likes = msg.Likes; - UserLike = msg.UserLike; + setLiked(msg.isLiked()); childs = msg.childs; PM = msg.PM; Recommendation = msg.Recommendation; @@ -156,8 +156,8 @@ public class Message implements Comparable { public String getTagsString() { String ret = ""; if (!Tags.isEmpty()) { - for (int i = 0; i < Tags.size(); i++) { - ret += " *" + Tags.get(i); + for (String Tag : Tags) { + ret += " *" + Tag; } if (FriendsOnly) { ret += " *friends"; @@ -233,4 +233,12 @@ public class Message implements Comparable { public void setRecommendation(Recommendation recommendation) { this.Recommendation = Optional.ofNullable(recommendation); } + + public boolean isLiked() { + return liked; + } + + public void setLiked(boolean liked) { + this.liked = liked; + } } diff --git a/src/main/java/com/juick/User.java b/src/main/java/com/juick/User.java index 40a3df96..13df2058 100644 --- a/src/main/java/com/juick/User.java +++ b/src/main/java/com/juick/User.java @@ -28,9 +28,9 @@ public class User { public Object Avatar = null; private String FullName = null; private String JID = null; - public int MessagesCount = 0; + private int unreadCount; private String AuthHash = null; - public boolean Banned = false; + private boolean banned = false; public User() { } @@ -41,9 +41,9 @@ public class User { Avatar = u.Avatar; setFullName(u.getFullName()); setJID(u.getJID()); - MessagesCount = u.MessagesCount; + setUnreadCount(u.getUnreadCount()); setAuthHash(u.getAuthHash()); - Banned = u.Banned; + setBanned(u.isBanned()); } @Override @@ -90,4 +90,20 @@ public class User { public void setAuthHash(String authHash) { AuthHash = authHash; } + + public int getUnreadCount() { + return unreadCount; + } + + public void setUnreadCount(int unreadCount) { + this.unreadCount = unreadCount; + } + + public boolean isBanned() { + return banned; + } + + public void setBanned(boolean banned) { + this.banned = banned; + } } -- cgit v1.2.3