-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLink.java
More file actions
61 lines (45 loc) · 1.36 KB
/
Link.java
File metadata and controls
61 lines (45 loc) · 1.36 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
package webapp.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import java.io.Serializable;
import java.util.Objects;
import static webapp.model.Section.EMPTY_STRING;
@XmlAccessorType(XmlAccessType.FIELD)
public class Link implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private String url;
public Link(String name, String url) {
Objects.requireNonNull(name, "name must not be null");
this.name = name;
this.url = url == null ? EMPTY_STRING : url;
}
public Link(String name) {
this(name, EMPTY_STRING);
}
public Link() {
}
public String getName() {
return name;
}
public String getUrl() {
return url;
}
@Override
public String toString() {
return "Link(" + name + ',' + url + ')';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Link link = (Link) o;
return name.equals(link.name) && (url != null ? url.equals(link.url) : link.url == null);
}
@Override
public int hashCode() {
int result = name.hashCode();
result = 31 * result + (url != null ? url.hashCode() : 0);
return result;
}
}