Skip to content

Commit

Permalink
Change deepClone to clone #52
Browse files Browse the repository at this point in the history
  • Loading branch information
brsanthu committed May 20, 2019
1 parent fcf5f8f commit 6ac22c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
* @author Santhosh Kumar
*/
@SuppressWarnings("unchecked")
public class GoogleAnalyticsRequest<T> {
public class GoogleAnalyticsRequest<T> implements Cloneable {

public static final String HIT_SCREENVIEW = "screenview";
public static final String HIT_PAGEVIEW = "pageview";
Expand Down Expand Up @@ -1915,7 +1915,8 @@ public ZonedDateTime occurredAt() {
* Deep clones this hit and returns new request of same type. Any changes made to this request after this call, will
* not be reflected in the returned instance.
*/
public T deepClone() {
@Override
public T clone() {
try {
GoogleAnalyticsRequest<T> clonedReq = this.getClass().newInstance();
clonedReq.occurredAt = ZonedDateTime.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void testAutoQueueTimeBatch() throws Exception {
@Test
void testDeepClone() throws Exception {
ScreenViewHit screenhit1 = ga.screenView().adwordsId("test1");
ScreenViewHit screenhit2 = screenhit1.deepClone();
ScreenViewHit screenhit2 = screenhit1.clone();

screenhit1.adwordsId("test1updated");

Expand Down Expand Up @@ -259,7 +259,7 @@ void testAnyHit() throws Exception {
anyhit1.adwordsId("adsid456");
assertThat(sv.adwordsId()).isEqualTo(anyhit1.adwordsId());

AnyHit anyhit2 = sv.deepClone().asAnyHit();
AnyHit anyhit2 = sv.clone().asAnyHit();
anyhit2.adwordsId("adsid789");
assertThat(sv.adwordsId()).isNotEqualTo(anyhit2.adwordsId());
}
Expand Down

0 comments on commit 6ac22c5

Please sign in to comment.