1 package com.trendmicro.grid.acl.ds.jpa.entities;
2
3 import javax.persistence.*;
4
5 import static net.sf.tinyjee.util.Assert.assertNotNull;
6
7
8
9
10
11
12
13 @Embeddable
14 public class JpaNamedFileIdentifierHistoryId extends AbstractJpaNamedFileIdentifierId {
15
16 private static final long serialVersionUID = -2155156736151475015L;
17
18 @ManyToOne(optional = false, fetch = FetchType.LAZY)
19 @JoinColumn(name = "FILE_CONTENT_ID", nullable = false, updatable = false)
20 private JpaFileDetails fileDetails;
21
22 @Column(name = "REVISION", nullable = false)
23 private int revision;
24
25 public JpaNamedFileIdentifierHistoryId() {
26 }
27
28 public JpaNamedFileIdentifierHistoryId(JpaFileDetails fileDetails,
29 JpaPackageDetails packageDetails,
30 String fileName, int revision) {
31 super(packageDetails, fileName);
32 assertNotNull("JpaFileDetails", fileDetails);
33 this.fileDetails = fileDetails;
34 this.revision = revision;
35 }
36
37 public JpaFileDetails getFileDetails() {
38 return fileDetails;
39 }
40
41 public int getRevision() {
42 return revision;
43 }
44
45 @Override
46 public boolean equals(Object o) {
47 if (this == o) return true;
48 if (!(o instanceof JpaNamedFileIdentifierHistoryId)) return false;
49 if (!super.equals(o)) return false;
50
51 JpaNamedFileIdentifierHistoryId that = (JpaNamedFileIdentifierHistoryId) o;
52 return revision == that.revision && fileDetails.equals(that.fileDetails);
53 }
54
55 @Override
56 public int hashCode() {
57 int result = super.hashCode();
58 result = 31 * result + fileDetails.hashCode();
59 result = 31 * result + revision;
60 return result;
61 }
62
63 @Override
64 public String toString() {
65 return "JpaNamedFileIdentifierHistoryId{" +
66 "packageDetails=" + getPackageDetails() +
67 ", fileDetails=" + fileDetails +
68 ", fileName=" + getFileName() +
69 ", revision=" + revision +
70 '}';
71 }
72 }