You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.2 KiB

package com.example.datacollect.model;
import java.time.LocalDate;
import java.util.Objects;
/**
* 文章实体类
* 用于存储文章的相关信息
*/
public class Article {
private String title;
private String url;
private String content;
private String author;
private LocalDate publishDate;
/**
* 无参构造方法
*/
public Article() {
}
/**
* 全参构造方法
* @param title 文章标题
* @param url 文章URL
* @param content 文章内容
* @param author 作者
* @param publishDate 发布日期
*/
public Article(String title, String url, String content, String author, LocalDate publishDate) {
this.title = title;
this.url = url;
this.content = content;
this.author = author;
this.publishDate = publishDate;
}
// Getter 和 Setter 方法
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public LocalDate getPublishDate() {
return publishDate;
}
public void setPublishDate(LocalDate publishDate) {
this.publishDate = publishDate;
}
@Override
public String toString() {
return "Article{"
+ "title='" + title + '\''
+ ", url='" + url + '\''
+ ", content='" + content + '\''
+ ", author='" + author + '\''
+ ", publishDate=" + publishDate
+ '}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Article article = (Article) o;
return Objects.equals(url, article.url);
}
@Override
public int hashCode() {
return Objects.hash(url);
}
}