-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContactType.java
67 lines (56 loc) · 1.78 KB
/
ContactType.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
import java.io.Serializable;
import java.time.LocalDateTime;
public class ContactType implements Serializable {
public final static long serialVersionUID = 1L;
private String number;
private String name;
private LocalDateTime timeCreated;
private LocalDateTime timeLastModified;
public ContactType() {
this.number = "[no number]";
this.timeCreated = LocalDateTime.now();
this.timeLastModified = LocalDateTime.now();
}
public ContactType(String number, String name) {
this.name = name;
if(number.matches("\\+?\\d?.{0,2}\\d{3}.{0,2}\\d{3}.{0,2}\\d{2}.?\\d{2}")) {
this.number = number;
}
else{
this.number = "[no number]";
}
this.timeCreated = LocalDateTime.now();
this.timeLastModified = LocalDateTime.now();
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
if(number.matches("\\+?\\d?.{0,2}\\d{3}.{0,2}\\d{3}.{0,2}\\d{2}.?\\d{2}")) {
this.timeLastModified = LocalDateTime.now();
this.number = number;
}
else{
System.out.println("Wrong number format!");
}
}
public String getName() {
return name;
}
public void setName(String name) {
this.timeLastModified = LocalDateTime.now();
this.name = name;
}
public LocalDateTime getTimeCreated() {
return timeCreated;
}
public void setTimeCreated(LocalDateTime timeCreated) {
this.timeCreated = timeCreated;
}
public LocalDateTime getTimeLastModified() {
return timeLastModified;
}
public void setTimeLastModified(LocalDateTime timeLastModified) {
this.timeLastModified = timeLastModified;
}
}