-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDocumentVersion.java
More file actions
87 lines (73 loc) · 2.53 KB
/
DocumentVersion.java
File metadata and controls
87 lines (73 loc) · 2.53 KB
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
82
83
84
85
86
87
package com.example;
import java.sql.Timestamp;
public class DocumentVersion {
private int version;
private String content;
private String filename;
private Timestamp createdAt;
// Constructor
public DocumentVersion(int version, String content, String filename, Timestamp createdAt) {
if (content == null || content.trim().isEmpty()) {
throw new IllegalArgumentException("Content cannot be null or empty");
}
if (filename == null || filename.trim().isEmpty()) {
throw new IllegalArgumentException("Filename cannot be null or empty");
}
this.version = version;
this.content = content;
this.filename = filename;
this.createdAt = createdAt;
}
// Getters and Setters
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public String getContent() {
return content;
}
public void setContent(String content) {
if (content == null || content.trim().isEmpty()) {
throw new IllegalArgumentException("Content cannot be null or empty");
}
this.content = content;
}
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
if (filename == null || filename.trim().isEmpty()) {
throw new IllegalArgumentException("Filename cannot be null or empty");
}
this.filename = filename;
}
public Timestamp getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Timestamp createdAt) {
this.createdAt = createdAt;
}
@Override
public String toString() {
return "Version: " + version + "\n" +
"Content: " + content + "\n" +
"Filename: " + filename + "\n" +
"Created At: " + createdAt;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
DocumentVersion that = (DocumentVersion) obj;
return version == that.version &&
content.equals(that.content) &&
filename.equals(that.filename) &&
createdAt.equals(that.createdAt);
}
@Override
public int hashCode() {
return 31 * version + content.hashCode() + filename.hashCode() + createdAt.hashCode();
}
}