Line | |
---|
1 | package geniusweb.references;
|
---|
2 |
|
---|
3 | import java.net.URI;
|
---|
4 | import java.net.URISyntaxException;
|
---|
5 |
|
---|
6 | import com.fasterxml.jackson.annotation.JsonCreator;
|
---|
7 | import com.fasterxml.jackson.annotation.JsonValue;
|
---|
8 |
|
---|
9 | /**
|
---|
10 | * A URL reference to a Domain: the place where this domain is stored.
|
---|
11 | */
|
---|
12 | public class DomainRef implements Reference {
|
---|
13 | @JsonValue
|
---|
14 | private URI uri;
|
---|
15 |
|
---|
16 | @JsonCreator // special: we need a URI so no @JsonProperty here
|
---|
17 | public DomainRef(String uri) throws URISyntaxException {
|
---|
18 | this(new URI(uri));
|
---|
19 | }
|
---|
20 |
|
---|
21 | public DomainRef(URI url) {
|
---|
22 | this.uri = url;
|
---|
23 | }
|
---|
24 |
|
---|
25 | @Override
|
---|
26 | public int hashCode() {
|
---|
27 | final int prime = 31;
|
---|
28 | int result = 1;
|
---|
29 | result = prime * result + ((uri == null) ? 0 : uri.hashCode());
|
---|
30 | return result;
|
---|
31 | }
|
---|
32 |
|
---|
33 | @Override
|
---|
34 | public boolean equals(Object obj) {
|
---|
35 | if (this == obj)
|
---|
36 | return true;
|
---|
37 | if (obj == null)
|
---|
38 | return false;
|
---|
39 | if (getClass() != obj.getClass())
|
---|
40 | return false;
|
---|
41 | DomainRef other = (DomainRef) obj;
|
---|
42 | if (uri == null) {
|
---|
43 | if (other.uri != null)
|
---|
44 | return false;
|
---|
45 | } else if (!uri.equals(other.uri))
|
---|
46 | return false;
|
---|
47 | return true;
|
---|
48 | }
|
---|
49 |
|
---|
50 | @Override
|
---|
51 | public URI getURI() {
|
---|
52 | return uri;
|
---|
53 | }
|
---|
54 |
|
---|
55 | @Override
|
---|
56 | public String toString() {
|
---|
57 | return "DomainRef[" + uri + "]";
|
---|
58 | }
|
---|
59 |
|
---|
60 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.