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.
65 lines
1.6 KiB
65 lines
1.6 KiB
public class Article {
|
|
private String title;
|
|
private String url;
|
|
private String content;
|
|
private long timestamp;
|
|
|
|
public Article(String title, String url) {
|
|
if (title == null || title.trim().isEmpty()) {
|
|
throw new IllegalArgumentException("标题不能为空");
|
|
}
|
|
if (url == null || url.trim().isEmpty()) {
|
|
throw new IllegalArgumentException("URL不能为空");
|
|
}
|
|
this.title = title;
|
|
this.url = url;
|
|
this.timestamp = System.currentTimeMillis();
|
|
}
|
|
|
|
public String getTitle() {
|
|
return title;
|
|
}
|
|
|
|
public void setTitle(String title) {
|
|
if (title == null || title.trim().isEmpty()) {
|
|
throw new IllegalArgumentException("标题不能为空");
|
|
}
|
|
this.title = title;
|
|
}
|
|
|
|
public String getUrl() {
|
|
return url;
|
|
}
|
|
|
|
public void setUrl(String url) {
|
|
if (url == null || url.trim().isEmpty()) {
|
|
throw new IllegalArgumentException("URL不能为空");
|
|
}
|
|
this.url = url;
|
|
}
|
|
|
|
public String getContent() {
|
|
return content;
|
|
}
|
|
|
|
public void setContent(String content) {
|
|
this.content = content;
|
|
}
|
|
|
|
public long getTimestamp() {
|
|
return timestamp;
|
|
}
|
|
|
|
public void setTimestamp(long timestamp) {
|
|
this.timestamp = timestamp;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "Article{" +
|
|
"title='" + title + '\'' +
|
|
", url='" + url + '\'' +
|
|
", timestamp=" + timestamp +
|
|
'}';
|
|
}
|
|
}
|