Changeset 226 for VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/model/Resource.java
- Timestamp:
- 03/15/10 18:10:30 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/model/Resource.java
r146 r226 2 2 3 3 import javax.persistence.Column; 4 import javax.persistence.DiscriminatorColumn;5 import javax.persistence.DiscriminatorType;6 4 import javax.persistence.Entity; 5 import javax.persistence.EnumType; 6 import javax.persistence.Enumerated; 7 7 import javax.persistence.GeneratedValue; 8 8 import javax.persistence.GenerationType; 9 9 import javax.persistence.Id; 10 import javax.persistence.Inheritance;11 import javax.persistence.InheritanceType;12 10 import javax.persistence.Table; 13 11 import javax.xml.bind.annotation.XmlAccessType; 14 12 import javax.xml.bind.annotation.XmlAccessorType; 15 13 import javax.xml.bind.annotation.XmlAttribute; 14 import javax.xml.bind.annotation.XmlElement; 16 15 import javax.xml.bind.annotation.XmlID; 17 import javax.xml.bind.annotation.XmlSeeAlso; 16 import javax.xml.bind.annotation.XmlType; 17 18 import org.apache.commons.lang.builder.HashCodeBuilder; 18 19 19 20 @Entity 20 21 @Table(name = "resource") 21 @Inheritance(strategy = InheritanceType.SINGLE_TABLE)22 @DiscriminatorColumn(discriminatorType=DiscriminatorType.STRING, length=1)23 22 @XmlAccessorType(XmlAccessType.NONE) 24 @Xml SeeAlso({ ResourceProxy.class, ResourceMetadata.class})25 public abstractclass Resource {23 @XmlType(propOrder = { "type", "ref" }) 24 public class Resource { 26 25 @Id 27 26 @GeneratedValue(strategy = GenerationType.AUTO) 28 27 @Column(name = "id", nullable = false, updatable = false, insertable = true) 29 28 private long id = -1; 29 @Column(name = "type", nullable = false) 30 @Enumerated(EnumType.ORDINAL) 31 private ResourceType type; 32 @Column(name = "ref", nullable = false) 33 private String ref; 30 34 31 pr otectedResource() {35 private Resource() { 32 36 super(); 37 } 38 39 public Resource(ResourceType type, String ref) { 40 this(); 41 this.setType(type); 42 this.setRef(ref); 33 43 } 34 44 … … 42 52 return "r" + id; 43 53 } 44 45 public abstract ResourceType getType();46 54 47 public abstract String getRef(); 55 public void setType(ResourceType type) { 56 if (type == null) { 57 throw new NullPointerException("type == null"); 58 } 59 this.type = type; 60 } 48 61 49 abstract int getSignature(); 62 @XmlElement(name = "ResourceType") 63 public ResourceType getType() { 64 return type; 65 } 50 66 51 } // abstract class Resource 67 public void setRef(String ref) { 68 if (ref == null) { 69 throw new NullPointerException("ref == null"); 70 } 71 this.ref = ref; 72 } 73 74 @XmlElement(name = "ResourceRef") 75 public String getRef() { 76 return ref; 77 } 78 79 protected int getSignature() { 80 return new HashCodeBuilder(799, 51) 81 .append(type) 82 .append(ref) 83 .toHashCode(); 84 } 85 86 } // class Resource
Note: See TracChangeset
for help on using the changeset viewer.