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 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 | */
|
---|
18 | public 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 | }
|
---|