01: package org.osbl.persistence.model;
02:
03: import org.conform.Property;
04: import org.hibernate.Hibernate;
05:
06: public abstract class Concrete<G extends General> {
07: @Property(writable="false")
08: Long id;
09: @Property(writable="false")
10: G general;
11:
12: public Concrete() {
13: }
14:
15: public Concrete(G general) {
16: setGeneral(general);
17: }
18:
19: public Long getId() {
20: return id;
21: }
22:
23: public void setId(Long id) {
24: this .id = id;
25: }
26:
27: public G getGeneral() {
28: return general;
29: }
30:
31: public void setGeneral(G general) {
32: if (this .general != null)
33: this .general.removeConcrete(this );
34: this .general = general;
35: if (this .general != null)
36: this .general.addConcrete(this );
37: }
38:
39: public String toString() {
40: return (general != null ? general.getClass().getSimpleName()
41: : "")
42: + " -> " + getClass().getSimpleName();
43: }
44:
45: public boolean equals(Object o) {
46: if (this == o)
47: return true;
48: if (o == null)
49: return false;
50:
51: Concrete concrete = (Concrete) o;
52:
53: if (getGeneral() != null ? !getGeneral().equals(
54: concrete.getGeneral()) : concrete.getGeneral() != null)
55: return false;
56:
57: return true;
58: }
59:
60: public int hashCode() {
61: return (getGeneral() != null ? getGeneral().hashCode() : 0);
62: }
63: }
|