01: /*
02: * Copyright 2006 Davide Deidda
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: /*
18: * Course.java
19: *
20: * Created on 25 aprile 2005, 10.01
21: */
22:
23: package it.biobytes.ammentos.test;
24:
25: import it.biobytes.ammentos.*;
26: import static it.biobytes.ammentos.FieldTypeEnum.*;
27:
28: @PersistentEntity(sourceDomain="courses",targetDomain="courses",primaryKey="code")
29: public class Course implements Comparable {
30: @PersistentField(fieldName="code",description="course code",type=STRING)
31: private String m_code;
32:
33: @PersistentField(fieldName="description",description="course description",type=STRING)
34: private String m_description;
35:
36: @PersistentField(fieldName="teacher_id",description="course teacher")
37: private Teacher m_teacher;
38:
39: /** Creates a new instance of Course */
40: public Course(String code) {
41: m_code = code;
42: }
43:
44: private Course() {
45: }
46:
47: public String getCode() {
48: return m_code;
49: }
50:
51: public Teacher getTeacher() {
52: return m_teacher;
53: }
54:
55: public void setTeacher(Teacher m_teacher) {
56: this .m_teacher = m_teacher;
57: }
58:
59: public String getDescription() {
60: return m_description;
61: }
62:
63: public void setDescription(String m_description) {
64: this .m_description = m_description;
65: }
66:
67: public boolean equals(Object obj) {
68: boolean res = false;
69: try {
70: res = (obj != null)
71: && (Ammentos.diff(this , obj).size() == 0);
72: } catch (Exception e) {
73:
74: }
75: return res;
76: }
77:
78: public int hashCode() {
79: return (m_code == null) ? 0 : m_code.hashCode();
80: }
81:
82: public int compareTo(Object o) {
83: int res = -1;
84: try {
85: res = m_code.compareTo(((Course) o).m_code);
86: } catch (Exception e) {
87: }
88: return res;
89: }
90:
91: public String toString() {
92: return m_code;
93: }
94:
95: }
|