Rev | Line | |
---|
[49] | 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 create a new instance of a party on a party factory
|
---|
| 11 | * server. These are used to describe sesion and tournament settings.
|
---|
| 12 | */
|
---|
| 13 | public class PartyRef implements Reference {
|
---|
| 14 | @JsonValue
|
---|
| 15 | private URI party;
|
---|
| 16 |
|
---|
| 17 | @JsonCreator
|
---|
| 18 | public PartyRef(String uri) throws URISyntaxException {
|
---|
| 19 | if (uri == null) {
|
---|
| 20 | throw new IllegalArgumentException("uri=null");
|
---|
| 21 | }
|
---|
| 22 | this.party = new URI(uri);
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | public PartyRef(URI uri) {
|
---|
| 26 | if (uri == null) {
|
---|
| 27 | throw new IllegalArgumentException("uri=null");
|
---|
| 28 | }
|
---|
| 29 | this.party = uri;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | @Override
|
---|
| 33 | public URI getURI() {
|
---|
| 34 | return party;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | @Override
|
---|
| 38 | public String toString() {
|
---|
| 39 | return "PartyRef[" + party + "]";
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | @Override
|
---|
| 43 | public int hashCode() {
|
---|
| 44 | final int prime = 31;
|
---|
| 45 | int result = 1;
|
---|
| 46 | result = prime * result + ((party == null) ? 0 : party.hashCode());
|
---|
| 47 | return result;
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | @Override
|
---|
| 51 | public boolean equals(Object obj) {
|
---|
| 52 | if (this == obj)
|
---|
| 53 | return true;
|
---|
| 54 | if (obj == null)
|
---|
| 55 | return false;
|
---|
| 56 | if (getClass() != obj.getClass())
|
---|
| 57 | return false;
|
---|
| 58 | PartyRef other = (PartyRef) obj;
|
---|
| 59 | if (party == null) {
|
---|
| 60 | if (other.party != null)
|
---|
| 61 | return false;
|
---|
| 62 | } else if (!party.equals(other.party))
|
---|
| 63 | return false;
|
---|
| 64 | return true;
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.