aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/Message.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/Message.java')
-rw-r--r--src/main/java/com/juick/Message.java56
1 files changed, 41 insertions, 15 deletions
diff --git a/src/main/java/com/juick/Message.java b/src/main/java/com/juick/Message.java
index 003622ec..c128b4f2 100644
--- a/src/main/java/com/juick/Message.java
+++ b/src/main/java/com/juick/Message.java
@@ -17,15 +17,13 @@
*/
package com.juick;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
+import java.util.*;
/**
*
* @author Ugnich Anton
*/
-public class Message {
+public class Message implements Comparable {
private int MID = 0;
@@ -34,8 +32,8 @@ public class Message {
public int ReplyTo = 0;
private String Text = null;
private User User = null;
- public ArrayList<String> Tags = new ArrayList<String>();
- private Date date = null;
+ public List<String> Tags = new ArrayList<>();
+ private Date date;
public int TimeAgo = 0;
public int Privacy = 1;
public boolean FriendsOnly = false;
@@ -49,8 +47,10 @@ public class Message {
public String Video = null;
public Place Place = null;
public int Likes = 0;
- public boolean UserLike = false;
- public ArrayList<Message> childs = new ArrayList<Message>();
+ private boolean liked = false;
+ public List<Message> childs = new ArrayList<>();
+ private Optional<PM> PM = Optional.empty();
+ private Optional<Recommendation> Recommendation = Optional.empty();
public Message() {
}
@@ -74,8 +74,10 @@ public class Message {
Video = msg.Video;
Place = msg.Place;
Likes = msg.Likes;
- UserLike = msg.UserLike;
+ setLiked(msg.isLiked());
childs = msg.childs;
+ PM = msg.PM;
+ Recommendation = msg.Recommendation;
}
public void parseTags(String strTags) {
@@ -93,6 +95,7 @@ public class Message {
return (this.getMID() == jmsg.getMID() && this.getRID() == jmsg.getRID());
}
+ @Override
public int compareTo(Object obj) throws ClassCastException {
if (!(obj instanceof Message)) {
throw new ClassCastException();
@@ -120,16 +123,16 @@ public class Message {
public int getChildsCount() {
int cnt = childs.size();
- for (int i = 0; i < childs.size(); i++) {
- cnt += childs.get(i).getChildsCount();
+ for (Message child : childs) {
+ cnt += child.getChildsCount();
}
return cnt;
}
public void cleanupChilds() {
if (!childs.isEmpty()) {
- for (int i = 0; i < childs.size(); i++) {
- childs.get(i).cleanupChilds();
+ for (Message child : childs) {
+ child.cleanupChilds();
}
childs.clear();
}
@@ -153,8 +156,8 @@ public class Message {
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";
@@ -215,4 +218,27 @@ public class Message {
this.date = date;
}
+
+ public Optional<com.juick.PM> getPM() {
+ return PM;
+ }
+
+ public void setPM(com.juick.PM PM) {
+ this.PM = Optional.ofNullable(PM);
+ }
+
+ public Optional<Recommendation> getRecommendation() {
+ return Recommendation;
+ }
+ public void setRecommendation(Recommendation recommendation) {
+ this.Recommendation = Optional.ofNullable(recommendation);
+ }
+
+ public boolean isLiked() {
+ return liked;
+ }
+
+ public void setLiked(boolean liked) {
+ this.liked = liked;
+ }
}