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