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 create a new instance of a party on a party factory * server. These are used to describe sesion and tournament settings. */ public class PartyRef implements Reference { @JsonValue private URI party; @JsonCreator public PartyRef(String uri) throws URISyntaxException { if (uri == null) { throw new IllegalArgumentException("uri=null"); } this.party = new URI(uri); } public PartyRef(URI uri) { if (uri == null) { throw new IllegalArgumentException("uri=null"); } this.party = uri; } @Override public URI getURI() { return party; } @Override public String toString() { return "PartyRef[" + party + "]"; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((party == null) ? 0 : party.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; PartyRef other = (PartyRef) obj; if (party == null) { if (other.party != null) return false; } else if (!party.equals(other.party)) return false; return true; } }