1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.promotego.beans;
20
21 import javax.persistence.GeneratedValue;
22 import javax.persistence.GenerationType;
23 import javax.persistence.Id;
24 import javax.persistence.MappedSuperclass;
25
26 import org.apache.commons.lang.builder.EqualsBuilder;
27 import org.apache.commons.lang.builder.HashCodeBuilder;
28 import org.apache.commons.lang.builder.ToStringBuilder;
29 import org.promotego.exceptions.NestedException;
30
31 @MappedSuperclass
32 public class BeanSupport<T> implements Cloneable
33 {
34 private Long m_id;
35
36 @Id
37 @GeneratedValue(strategy = GenerationType.AUTO)
38 public Long getId()
39 {
40 return m_id;
41 }
42
43 public void setId(Long id)
44 {
45 m_id = id;
46 }
47
48 @SuppressWarnings("unchecked")
49 @Override
50 public T clone()
51 {
52 try
53 {
54 return (T)super.clone();
55 }
56 catch (CloneNotSupportedException e)
57 {
58
59 throw NestedException.wrap(e);
60 }
61 }
62
63 @Override
64 public boolean equals(Object anotherObject)
65 {
66 return EqualsBuilder.reflectionEquals(this, anotherObject);
67 }
68
69 @Override
70 public int hashCode()
71 {
72 return HashCodeBuilder.reflectionHashCode(this);
73 }
74
75 @Override
76 public String toString()
77 {
78 return ToStringBuilder.reflectionToString(this).toString();
79 }
80 }