1 | package eu.clarin.cmdi.virtualcollectionregistry.model; |
---|
2 | |
---|
3 | import javax.persistence.Column; |
---|
4 | import javax.persistence.DiscriminatorValue; |
---|
5 | import javax.persistence.Entity; |
---|
6 | import javax.persistence.EnumType; |
---|
7 | import javax.persistence.Enumerated; |
---|
8 | import javax.persistence.Table; |
---|
9 | import javax.xml.bind.annotation.XmlAccessType; |
---|
10 | import javax.xml.bind.annotation.XmlAccessorType; |
---|
11 | import javax.xml.bind.annotation.XmlElement; |
---|
12 | import javax.xml.bind.annotation.XmlRootElement; |
---|
13 | import javax.xml.bind.annotation.XmlSeeAlso; |
---|
14 | import javax.xml.bind.annotation.XmlType; |
---|
15 | |
---|
16 | import org.apache.commons.lang.builder.HashCodeBuilder; |
---|
17 | |
---|
18 | @Entity |
---|
19 | @DiscriminatorValue("P") |
---|
20 | @XmlRootElement(name = "ResourceProxy") |
---|
21 | @XmlAccessorType(XmlAccessType.NONE) |
---|
22 | @XmlType(namespace = "urn:x-vcr:virtualcollection:resourceproxy", |
---|
23 | propOrder = { "type", "ref" }) |
---|
24 | @XmlSeeAlso({ Resource.class }) |
---|
25 | public class ResourceProxy extends Resource { |
---|
26 | @Column(name = "type") |
---|
27 | @Enumerated(EnumType.ORDINAL) |
---|
28 | private ResourceType type = ResourceType.METADATA; |
---|
29 | @Column(name = "ref", nullable = false) |
---|
30 | private String ref; |
---|
31 | |
---|
32 | @SuppressWarnings("unused") |
---|
33 | private ResourceProxy() { |
---|
34 | super(); |
---|
35 | } |
---|
36 | |
---|
37 | public ResourceProxy(ResourceType type, String ref) { |
---|
38 | super(); |
---|
39 | this.setType(type); |
---|
40 | this.setRef(ref); |
---|
41 | } |
---|
42 | |
---|
43 | public void setType(ResourceType type) { |
---|
44 | if (type == null) { |
---|
45 | throw new IllegalArgumentException("type == null"); |
---|
46 | } |
---|
47 | this.type = type; |
---|
48 | } |
---|
49 | |
---|
50 | @XmlElement(name = "ResourceType") |
---|
51 | public ResourceType getType() { |
---|
52 | return type; |
---|
53 | } |
---|
54 | |
---|
55 | public void setRef(String ref) { |
---|
56 | if (ref == null) { |
---|
57 | throw new IllegalArgumentException("ref == null"); |
---|
58 | } |
---|
59 | this.ref = ref; |
---|
60 | } |
---|
61 | |
---|
62 | @XmlElement(name = "ResourceRef") |
---|
63 | public String getRef() { |
---|
64 | return ref; |
---|
65 | } |
---|
66 | |
---|
67 | int getSignature() { |
---|
68 | return new HashCodeBuilder(799, 51) |
---|
69 | .append(type) |
---|
70 | .append(ref) |
---|
71 | .toHashCode(); |
---|
72 | } |
---|
73 | |
---|
74 | } // class ResourceProxy |
---|