-
Notifications
You must be signed in to change notification settings - Fork 0
/
Group.java
77 lines (60 loc) · 1.75 KB
/
Group.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
import java.text.SimpleDateFormat;
import java.util.*;
/**
*
* @author jmcgr
*/
public class Group implements Composite, ComponentElement{
private List<Composite> listOfUserGroups = new ArrayList<>();
private String groupName;
private long timeOfCreation;
private SimpleDateFormat formattedTime = new SimpleDateFormat("MMM dd, yyyy HH:mm");
public Group(String newID){
setID(newID);
}
public Composite getUserGroup(int index){
return (Composite)listOfUserGroups.get(index);
}
public List getList(){
return listOfUserGroups;
}
public void add(Composite newUserGroup) {
listOfUserGroups.add(newUserGroup);
}
public void setID(String newID) {
groupName = newID;
}
@Override
public String getID() {
return groupName;
}
public String toString(){
String newString = "Group ID: " + this.getID();
return newString;
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Group)) {
return false;
}
Group group = (Group) obj;
return group.groupName.equals(groupName);
}
@Override
public void accept(ComponentVisitor visitor) {
visitor.visitGroups(this);
}
@Override
public String creationTime() {
Date formattedDate = new Date(this.timeOfCreation);
String newString = this.formattedTime.format(formattedDate);
return newString;
}
@Override
public void setCreationTime(long creationTime) {
this.timeOfCreation = creationTime;
}
}