1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity.domain.impl;
17
18 import org.acegisecurity.domain.PersistableEntity;
19
20 /***
21 * An abstract implementation of {@link
22 * org.acegisecurity.domain.PersistableEntity}.
23 *
24 * @author Ben Alex
25 * @version $Id: AbstractPersistableEntity.java,v 1.5 2005/11/17 00:55:49 benalex Exp $
26 *
27 *
28 */
29 public abstract class AbstractPersistableEntity extends BusinessObject
30 implements PersistableEntity {
31
32
33 public static final int STARTING_VERSION = 0;
34
35
36
37 private int version = STARTING_VERSION;
38
39
40
41 /***
42 * Indicates whether this persistable entity has been persisted yet.
43 * Determine based on whether the {@link #getInternalId()} returns
44 * <code>null</code> or a non-<code>null</code> value.
45 *
46 * @return <code>true</code> if the instance has not been persisted,
47 * <code>false</code> otherwise
48 */
49 public boolean isNew() {
50 return (getInternalId() == null);
51 }
52
53 /***
54 * Returns the version number, which should be managed by the persistence
55 * layer.
56 *
57 * <p>
58 * Initially all <code>PersistableEntity</code>s will commence with the
59 * version number defined by {@link #STARTING_VERSION}.
60 * </p>
61 *
62 * @return the version
63 */
64 public int getVersion() {
65 return version;
66 }
67
68 /***
69 * Sets the version numbers.
70 *
71 * @param version the new version number to use
72 */
73 public void setVersion(int version) {
74 this.version = version;
75 }
76 }