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