cleanup and refactored to move to net.wpitchoune package
[pnews.git] / war / src / main / java / net / wpitchoune / pnews / Article.java
diff --git a/war/src/main/java/net/wpitchoune/pnews/Article.java b/war/src/main/java/net/wpitchoune/pnews/Article.java
new file mode 100644 (file)
index 0000000..9445a24
--- /dev/null
@@ -0,0 +1,69 @@
+package net.wpitchoune.pnews;
+
+import java.time.Instant;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class Article {
+        private final String title;
+        private final String description;
+        private final String thumbnail;
+        private final String link;
+        private final Instant publicationDate;
+        private final String website;
+        private final String[] entities;
+        private final AtomicLong readCount = new AtomicLong();
+        
+        public Article(String link, String title, String description, String thumbnail, Instant publicationDate, String website, String[] entities) {
+                this.link = link;
+                this.title = title;
+                this.description = description;
+                this.thumbnail = thumbnail;
+                this.publicationDate = publicationDate;
+                this.website = website;
+                this.entities = entities;
+        }
+        
+        public String getTitle() {
+                return title;
+        }
+        
+        public String getDescription() {
+                return description;
+        }
+        
+        public String getLink() {
+                return link;
+        }
+        
+        public String getThumbnail() {
+                return thumbnail;
+        }
+        
+        public String getWebsite() {
+                return website;
+        }
+        
+        public long getReadCount() {
+                return readCount.get();
+        }
+        
+        public String[] getEntities() {
+                return entities;
+        }
+        
+        public boolean hasEntity(String entity) {
+                for (String e: entities)
+                        if (e.equals(entity))
+                                return true;
+                
+                return false;
+        }
+        
+        public Instant getPublicationDate() {
+                return publicationDate;
+        }
+
+        public void incrementReadCount() {
+                readCount.incrementAndGet();
+        }
+}