source: references/src/main/java/geniusweb/references/ProfileRef.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.7 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 URI reference to get a copy of a profile. This usually is a "ws://"
11 * (websocket) URI, allowing users (parties) to get notifications if the profile
12 * is changed.
13 * <p>
14 * In debugging scenarios, this is usually a "file://" URI, in which case the
15 * profile is assumed to be static during the run. Parties that support
16 * debugging eg with the simplerunner should support the file: protocol.
17 */
18public class ProfileRef implements Reference {
19 @JsonValue
20 private URI profile;
21
22 @JsonCreator // special: we need URI so no @JsonProperty
23 public ProfileRef(String uri) throws URISyntaxException {
24 if (uri == null) {
25 throw new IllegalArgumentException("uri=null");
26 }
27 this.profile = new URI(uri);
28 }
29
30 public ProfileRef(URI uri) {
31 if (uri == null) {
32 throw new IllegalArgumentException("uri=null");
33 }
34 this.profile = uri;
35 }
36
37 @Override
38 public URI getURI() {
39 return profile;
40 }
41
42 @Override
43 public String toString() {
44 return "ProfileRef[" + profile + "]";
45 }
46
47 @Override
48 public int hashCode() {
49 final int prime = 31;
50 int result = 1;
51 result = prime * result + ((profile == null) ? 0 : profile.hashCode());
52 return result;
53 }
54
55 @Override
56 public boolean equals(Object obj) {
57 if (this == obj)
58 return true;
59 if (obj == null)
60 return false;
61 if (getClass() != obj.getClass())
62 return false;
63 ProfileRef other = (ProfileRef) obj;
64 if (profile == null) {
65 if (other.profile != null)
66 return false;
67 } else if (!profile.equals(other.profile))
68 return false;
69 return true;
70 }
71}
Note: See TracBrowser for help on using the repository browser.