-
Notifications
You must be signed in to change notification settings - Fork 61
/
SearchItem.java
81 lines (67 loc) · 1.73 KB
/
SearchItem.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.airlocksoftware.hackernews.model;
import org.apache.commons.lang3.StringUtils;
public class SearchItem {
// public String _id;
// public boolean _noindex;
// public long _update_ts;
// public String cache_ts;
// public String create_ts;
// public String domain;
// public int id;
// public int num_comments;
// public int parent_id;
// public String parent_sigid;
// public int points;
// public String text;
// public String title;
// public String type;
// public String url;
// public String username;
// public Discussion discussion;
public String objectID;
public String title;
public String author;
public String created_at;
public long created_at_i;
public long points;
public long num_comments;
public String url;
public String story_text;
public String story_id;
public String parent_id;
public String comment_text;
public String story_title;
public String story_url;
@Override
public String toString() {
return "SearchItem [points=" + points
+ ", story_text=" + story_text
+ ", title=" + title
+ ", isTextPost=" + isTextPost()
+ ", url=" + url
+ ", story_title=" + url
+ ", story_url=" + url
+ ", author=" + author + "]";
}
public SearchItem() {
}
public boolean isArticlePost() {
// It's an article post if it has a URL
return StringUtils.isNotBlank(url);
}
public boolean isTextPost() {
// It's a text post if it doesn't have a URL or comment_text
return StringUtils.isNotBlank(story_text);
}
public boolean isComment() {
// It's a comment if it has comment_text
return StringUtils.isNotBlank(comment_text);
}
public String domain() {
if (url != null) {
return url.replaceAll("https?://(www.)?", "").replaceAll("/.*", "");
} else {
return "";
}
}
}