(no commit message)
[utils] / support / src / org / wamblee / persistence / AbstractPersistent.java
1 /*
2  * Copyright 2005 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.persistence;
18
19 import java.io.Serializable;
20
21 /**
22  * Default implementation of Persistent. 
23  */
24 public abstract class AbstractPersistent implements Persistent {
25     
26     /**
27      * Primary key. 
28      */
29     private Serializable _primaryKey; 
30     
31     /**
32      * Version. 
33      */
34     private int _version; 
35     
36     /**
37      * Constructs the object. 
38      *
39      */
40     protected AbstractPersistent() { 
41         _primaryKey = null; 
42         _version = -1; 
43     }
44     
45     /**
46      * Copy constructor. 
47      * @param aPersistent Object to copy. 
48      */
49     protected AbstractPersistent(AbstractPersistent aPersistent) {
50         _primaryKey = aPersistent._primaryKey; 
51         _version = aPersistent._version; 
52     }
53
54     /* (non-Javadoc)
55      * @see org.wamblee.persistence.Persistent#getPrimaryKey()
56      */
57     public Serializable getPrimaryKey() {
58         return _primaryKey; 
59     }
60     
61     /* (non-Javadoc)
62      * @see org.wamblee.persistence.Persistent#setPrimaryKey(java.io.Serializable)
63      */
64     public void setPrimaryKey(Serializable aKey) {
65         _primaryKey = aKey; 
66     }
67     
68     /* (non-Javadoc)
69      * @see org.wamblee.persistence.Persistent#getPersistedVersion()
70      */
71     public int getPersistedVersion() {
72         return _version; 
73     }
74     
75     /* (non-Javadoc)
76      * @see org.wamblee.persistence.Persistent#setPersistedVersion(int)
77      */
78     public void setPersistedVersion(int aVersion) {
79         _version = aVersion;
80     }
81 }