cleanup and refactored to move to net.wpitchoune package
[pnews.git] / war / src / main / java / net / wpitchoune / pnews / Article.java
1 package net.wpitchoune.pnews;
2
3 import java.time.Instant;
4 import java.util.concurrent.atomic.AtomicLong;
5
6 public class Article {
7         private final String title;
8         private final String description;
9         private final String thumbnail;
10         private final String link;
11         private final Instant publicationDate;
12         private final String website;
13         private final String[] entities;
14         private final AtomicLong readCount = new AtomicLong();
15         
16         public Article(String link, String title, String description, String thumbnail, Instant publicationDate, String website, String[] entities) {
17                 this.link = link;
18                 this.title = title;
19                 this.description = description;
20                 this.thumbnail = thumbnail;
21                 this.publicationDate = publicationDate;
22                 this.website = website;
23                 this.entities = entities;
24         }
25         
26         public String getTitle() {
27                 return title;
28         }
29         
30         public String getDescription() {
31                 return description;
32         }
33         
34         public String getLink() {
35                 return link;
36         }
37         
38         public String getThumbnail() {
39                 return thumbnail;
40         }
41         
42         public String getWebsite() {
43                 return website;
44         }
45         
46         public long getReadCount() {
47                 return readCount.get();
48         }
49         
50         public String[] getEntities() {
51                 return entities;
52         }
53         
54         public boolean hasEntity(String entity) {
55                 for (String e: entities)
56                         if (e.equals(entity))
57                                 return true;
58                 
59                 return false;
60         }
61         
62         public Instant getPublicationDate() {
63                 return publicationDate;
64         }
65
66         public void incrementReadCount() {
67                 readCount.incrementAndGet();
68         }
69 }