40ffd078796286a75db41eea6faa8cf6e7d290d8
[utils] / mythtv / monitor / src / main / java / org / wamblee / mythtv / RecordingPk.java
1 /*
2  * Copyright 2006 the original author or authors.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */ 
16
17 package org.wamblee.mythtv;
18
19 import java.io.Serializable;
20 import java.util.Date;
21
22 import javax.persistence.Column;
23 import javax.persistence.Embeddable;
24 import javax.persistence.Id;
25 import javax.persistence.JoinColumn;
26 import javax.persistence.ManyToOne;
27 import javax.persistence.Temporal;
28 import javax.persistence.TemporalType;
29
30 /**
31  * 
32  *
33  * @author Erik Brakkee
34  */
35 @Embeddable
36 public class RecordingPk implements Serializable {
37     public Channel _channel;
38     public Date _starttime;
39     
40     public RecordingPk() { 
41         // Empty
42     }
43     
44     /**
45      * @return the channel
46      */
47     @ManyToOne
48     @JoinColumn(name="chanid")
49     public Channel getChannel() {
50         return _channel;
51     }
52     
53     /**
54      * @param aChannel the channel to set
55      */
56     public void setChannel(Channel aChannel) {
57         _channel = aChannel;
58     }
59     
60     /**
61      * @return the starttime
62      */
63     @Column(name="starttime")
64     @Temporal(TemporalType.TIMESTAMP)
65     public Date getStartTime() {
66         return _starttime;
67     }
68
69     /**
70      * @param aStarttime the starttime to set
71      */
72     public void setStartTime(Date aStarttime) {
73         _starttime = aStarttime;
74     }
75     
76     /* (non-Javadoc)
77      * @see java.lang.Object#equals(java.lang.Object)
78      */
79     @Override
80     public boolean equals(Object aObj) {
81         if ( aObj == null ) { 
82             return false; 
83         }
84         if ( !(aObj instanceof RecordingPk)) { 
85             return false; 
86         }
87         RecordingPk pk = (RecordingPk) aObj;
88         return _channel.equals(pk._channel) && _starttime.equals(pk._starttime);   
89     }
90     
91     /* (non-Javadoc)
92      * @see java.lang.Object#hashCode()
93      */
94     @Override
95     public int hashCode() {
96         return _channel.hashCode() + _starttime.hashCode(); 
97     }
98     
99     /* (non-Javadoc)
100      * @see java.lang.Object#toString()
101      */
102     @Override
103     public String toString() {
104         return "pk(" + _channel + ", " + _starttime + ")"; 
105     }
106 }