package geniusweb.references; import java.net.URI; import java.net.URISyntaxException; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; /** * A URI reference to get a copy of a profile. This usually is a "ws://" * (websocket) URI, allowing users (parties) to get notifications if the profile * is changed. *

* In debugging scenarios, this is usually a "file://" URI, in which case the * profile is assumed to be static during the run. Parties that support * debugging eg with the simplerunner should support the file: protocol. */ public class ProfileRef implements Reference { @JsonValue private URI profile; @JsonCreator // special: we need URI so no @JsonProperty public ProfileRef(String uri) throws URISyntaxException { if (uri == null) { throw new IllegalArgumentException("uri=null"); } this.profile = new URI(uri); } public ProfileRef(URI uri) { if (uri == null) { throw new IllegalArgumentException("uri=null"); } this.profile = uri; } @Override public URI getURI() { return profile; } @Override public String toString() { return "ProfileRef[" + profile + "]"; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((profile == null) ? 0 : profile.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ProfileRef other = (ProfileRef) obj; if (profile == null) { if (other.profile != null) return false; } else if (!profile.equals(other.profile)) return false; return true; } }