| 1 |
|
package org.trails.io; |
| 2 |
|
|
| 3 |
|
import java.io.Serializable; |
| 4 |
|
|
| 5 |
|
public class EntityIdentity implements Serializable |
| 6 |
|
{ |
| 7 |
|
|
| 8 |
|
private static final long serialVersionUID = 1L; |
| 9 |
|
|
| 10 |
|
private final Class entityName; |
| 11 |
|
|
| 12 |
|
private final Serializable id; |
| 13 |
|
|
| 14 |
|
private final Object version; |
| 15 |
|
|
| 16 |
|
public EntityIdentity(Class entityName, Serializable id) |
| 17 |
|
{ |
| 18 |
0 |
this(entityName, id, null); |
| 19 |
0 |
} |
| 20 |
|
|
| 21 |
0 |
public EntityIdentity(Class entityName, Serializable id, Object version) |
| 22 |
|
{ |
| 23 |
0 |
this.entityName = entityName; |
| 24 |
0 |
this.id = id; |
| 25 |
0 |
this.version = version; |
| 26 |
0 |
} |
| 27 |
|
|
| 28 |
|
public Class getEntityName() |
| 29 |
|
{ |
| 30 |
0 |
return entityName; |
| 31 |
|
} |
| 32 |
|
|
| 33 |
|
public Serializable getId() |
| 34 |
|
{ |
| 35 |
0 |
return id; |
| 36 |
|
} |
| 37 |
|
|
| 38 |
|
public Object getVersion() |
| 39 |
|
{ |
| 40 |
0 |
return version; |
| 41 |
|
} |
| 42 |
|
|
| 43 |
|
public boolean equals(Object o) |
| 44 |
|
{ |
| 45 |
0 |
if (this == o) return true; |
| 46 |
0 |
if (o == null || getClass() != o.getClass()) return false; |
| 47 |
|
|
| 48 |
0 |
EntityIdentity that = (EntityIdentity) o; |
| 49 |
|
|
| 50 |
0 |
if (!entityName.equals(that.entityName)) return false; |
| 51 |
0 |
if (id != null ? !id.equals(that.id) : that.id != null) return false; |
| 52 |
|
|
| 53 |
0 |
return true; |
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
public int hashCode() |
| 57 |
|
{ |
| 58 |
|
int result; |
| 59 |
0 |
result = entityName.hashCode(); |
| 60 |
0 |
result = 31 * result + (id != null ? id.hashCode() : 0); |
| 61 |
0 |
return result; |
| 62 |
|
} |
| 63 |
|
} |