source: references/src/main/java/geniusweb/references/DomainRef.java@ 52

Last change on this file since 52 was 52, checked in by ruud, 14 months ago

Fixed small issues in domaineditor.

File size: 1.2 KB
Line 
1package geniusweb.references;
2
3import java.net.URI;
4import java.net.URISyntaxException;
5
6import com.fasterxml.jackson.annotation.JsonCreator;
7import com.fasterxml.jackson.annotation.JsonValue;
8
9/**
10 * A URL reference to a Domain: the place where this domain is stored.
11 */
12public 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.