-
Notifications
You must be signed in to change notification settings - Fork 0
/
Commit.java
84 lines (78 loc) · 2.18 KB
/
Commit.java
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
package gitlet;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TreeMap;
/** Represents a gitlet commit object.
* does at a high level.
*
* @author
*/
public class Commit implements Serializable {
/**
*
* List all instance variables of the Commit class here with a useful
* comment above them describing what that variable represents and how that
* variable is used. We've provided one example for `message`.
*/
/** The message of this Commit. */
private String message;
/**The timestamp for this Commit */
private Date timestamp;
/** Makes the initial commit */
private String parentid;
private String parentid2;
private TreeMap<String, String> map;
private String branch;
public Commit() {
this.message = "initial commit";
this.timestamp = new Date(0);
this.map = new TreeMap<>();
this.parentid = null;
this.branch = "master";
}
public Commit(String mess, String parentid) {
this.message = mess;
this.timestamp = new Date();
this.map = new TreeMap<>();
this.parentid = parentid;
this.parentid2 = null;
this.branch = null;
}
public String getformatedtime() {
String format = "E LLL d kk:mm:ss y Z";
DateFormat date = new SimpleDateFormat(format);
return date.format(timestamp);
}
public String getMessage() {
return this.message;
}
public Date gettimestamp() {
return this.timestamp;
}
public String getParentid() {
return this.parentid;
}
public String getParentid2() {
return this.parentid2;
}
public TreeMap<String, String> getmap() {
return this.map;
}
public String getBranch() {
return this.branch;
}
public void setparentid1(String given) {
this.parentid = given;
}
public void setbrancb(String given) {
this.branch = given;
}
public void setparentid2(String given) {
this.parentid2 = given;
}
public void setMap(TreeMap<String, String> map) {
this.map = map;
}
}