1 | |
package org.jtheque.core.managers.persistence; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
import org.jtheque.core.managers.persistence.able.Entity; |
20 | |
import org.jtheque.core.managers.persistence.context.TemporaryContext; |
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | 0 | public abstract class AbstractEntity implements Entity { |
28 | |
private int id; |
29 | |
|
30 | |
private final TemporaryContext temporaryContext; |
31 | |
|
32 | |
protected static final int HASHCODE_PRIME = 31; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
public AbstractEntity() { |
38 | 16 | super(); |
39 | |
|
40 | 16 | temporaryContext = new TemporaryContext(); |
41 | 16 | } |
42 | |
|
43 | |
@Override |
44 | |
public TemporaryContext getTemporaryContext() { |
45 | 0 | return temporaryContext; |
46 | |
} |
47 | |
|
48 | |
@Override |
49 | |
public final int getId() { |
50 | 120 | return id; |
51 | |
} |
52 | |
|
53 | |
@Override |
54 | |
public final void setId(int id) { |
55 | 16 | this.id = id; |
56 | 16 | } |
57 | |
|
58 | |
@Override |
59 | |
public final int compareTo(Entity object) { |
60 | 0 | return getDisplayableText().compareTo(object.getDisplayableText()); |
61 | |
} |
62 | |
|
63 | |
@Override |
64 | |
public abstract boolean equals(Object object); |
65 | |
|
66 | |
@Override |
67 | |
public abstract int hashCode(); |
68 | |
|
69 | |
@Override |
70 | |
public final boolean isSaved() { |
71 | 0 | return id != 0; |
72 | |
} |
73 | |
|
74 | |
@Override |
75 | |
public void saveToMemento() { |
76 | 0 | throw new UnsupportedOperationException(); |
77 | |
} |
78 | |
|
79 | |
@Override |
80 | |
public void restoreMemento() { |
81 | 0 | throw new UnsupportedOperationException(); |
82 | |
} |
83 | |
} |