Clover Coverage Report - Atlassian Core
Coverage timestamp: Sun Nov 30 2008 18:33:35 CST
20   94   15   1.82
10   60   0.75   11
11     1.36  
1    
 
 
  EntityObject       Line # 11 20 15 51.2% 0.5121951
 
  (1)
 
1    package com.atlassian.core.bean;
2   
3    import com.atlassian.core.util.Clock;
4   
5    import java.util.Date;
6   
7    /**
8    * Common superclass for persistent entities: provides a long key, and creation/modification
9    * dates. Also provides a clock for testing.
10    */
 
11    public class EntityObject implements Cloneable
12    {
13    private long id = 0;
14    private Date creationDate;
15    private Date lastModificationDate;
16   
17    private Clock clock;
18   
 
19  3 toggle public long getId()
20    {
21  3 return id;
22    }
23   
 
24  3 toggle public void setId(long id)
25    {
26  3 this.id = id;
27    }
28   
 
29  0 toggle public Date getCreationDate()
30    {
31  0 return creationDate;
32    }
33   
 
34  0 toggle public void setCreationDate(Date creationDate)
35    {
36  0 this.creationDate = creationDate;
37    }
38   
 
39  0 toggle public Date getLastModificationDate()
40    {
41  0 return lastModificationDate != null ? lastModificationDate : creationDate;
42    }
43   
 
44  0 toggle public void setLastModificationDate(Date lastModificationDate)
45    {
46  0 this.lastModificationDate = lastModificationDate;
47    }
48   
49    /**
50    * The clock is used to fool the entity into thinking that the current time is different
51    * to what it actually is. Used in tests so we get consistent results with time-based
52    * activities.
53    */
 
54  0 toggle public void setClock(Clock clock)
55    {
56  0 this.clock = clock;
57    }
58   
59    /**
60    * Consult the clock to get the current date.
61    *
62    * @return the current date as per the clock set in #setClock, or new Date() if
63    * no clock is set
64    */
 
65  0 toggle public Date getCurrentDate()
66    {
67  0 if (clock != null)
68  0 return clock.getCurrentDate();
69   
70  0 return new Date();
71    }
72   
 
73  4 toggle public int hashCode()
74    {
75  4 return (int) (id ^ (id >>> 32));
76    }
77   
 
78  5 toggle public boolean equals(Object o)
79    {
80  5 if (this == o) return true;
81  4 if (!(o instanceof EntityObject)) return false;
82   
83  3 final EntityObject entityObject = (EntityObject) o;
84   
85  3 if (id != entityObject.getId()) return false;
86   
87  2 return true;
88    }
89   
 
90  0 toggle public Object clone() throws CloneNotSupportedException
91    {
92  0 return super.clone();
93    }
94    }