/*
 *   Copyright(C) 2014 tAsktoys. All rights reserved.
 */
package com.tasktoys.archelon.data.entity;

import java.sql.Timestamp;

/**
 *
 * @author YuichiroSato
 * @since 0.2
 */
public class Activity {

    private final long id;
    private final ActivityType activityType;
    private final long userId;
    private final Timestamp createdTime;
    private final Long targetDiscussionId;
    private final Long targetUserId;
//    private final Long targetPostId;

    public enum ActivityType {

        CREATE_DISCUSSION, SOLVE_DISCUSSION, CLOSE_DISCUSSION;

        @Override
        public String toString() {
            return name().toLowerCase();
        }
    }

    private Activity(Builder builder) {
        this.id = builder.id;
        this.activityType = builder.activityType;
        this.userId = builder.userId;
        this.createdTime = builder.createdTime;
        this.targetDiscussionId = builder.targetDiscussionId;
        this.targetUserId = builder.targetUserId;
//        this.targetPostId = builder.targetPostId;
    }

    public long getId() {
        return id;
    }

    public ActivityType getActivityType() {
        return activityType;
    }

    public long getUserId() {
        return userId;
    }

    public Timestamp getCreatedTime() {
        return createdTime;
    }

    public Long getTargetDiscussionId() {
        return targetDiscussionId;
    }

    public Long getTargetUserId() {
        return targetUserId;
    }

    public static class Builder {

        public static final long ILLEGAL_ID = -1;
        public static final long ILLEGAL_USER_ID = -1;

        private long id = ILLEGAL_ID;
        private ActivityType activityType;
        private long userId = ILLEGAL_USER_ID;
        private Timestamp createdTime;
        private Long targetDiscussionId;
        private Long targetUserId;
//        private Long targetPostId;

        public Builder() {

        }

        public Builder id(long id) {
            if (id == ILLEGAL_ID) {
                throw new IllegalArgumentException("illegal id: " + id);
            }
            this.id = id;
            return this;
        }

        public Builder activityType(ActivityType activityType) {
            if (activityType == null) {
                throw new NullPointerException("activityTime is null");
            }
            this.activityType = activityType;
            return this;
        }

        public Builder userId(long userId) {
            if (userId == ILLEGAL_USER_ID) {
                throw new IllegalArgumentException("illegal usre id: " + userId);
            }
            this.userId = userId;
            return this;
        }

        public Builder createdTime(Timestamp createdTime) {
            if (createdTime == null) {
                throw new NullPointerException("createdTime is null");
            }
            this.createdTime = createdTime;
            return this;
        }

        public Builder targetDiscussionId(Long targetDiscussionId) {
            this.targetDiscussionId = targetDiscussionId;
            return this;
        }

        public Builder targetUserId(Long targetUserId) {
            this.targetUserId = targetUserId;
            return this;
        }

//        public Builder targetPostId(Long targetPostId) {
//            this.targetPostId = targetPostId;
//            return this;
//        }
        public Activity build() {
            if (this.id == ILLEGAL_ID) {
                throw new IllegalStateException("illegal id: " + id);
            }
            if (this.userId == ILLEGAL_USER_ID) {
                throw new IllegalStateException("illegal user id: " + userId);
            }
            if (this.activityType == null) {
                throw new IllegalStateException("activity type is null");
            }
            if (this.createdTime == null) {
                throw new IllegalStateException("created time is null");
            }
            return new Activity(this);
        }
    }
}

@@ -420,26 +420,24 @@
 rgetUserId;%0A
-//
     private 
@@ -438,28 +438,79 @@
 ivate final 
-Long
+String targetDiscussionContentId;%0A    private final int
  targetPostI
@@ -504,26 +504,24 @@
 t targetPost
-Id
 ;%0A%0A    publi
@@ -1028,34 +1028,32 @@
 r.targetUserId;%0A
-//
         this.tar
@@ -1051,27 +1051,40 @@
  this.target
-Pos
+DiscussionConten
 tId = builde
@@ -1091,22 +1091,81 @@
 r.target
+DiscussionContentId;%0A        this.targetPost = builder.target
 Post
-Id
 ;%0A    %7D%0A
@@ -1580,32 +1580,207 @@
 tUserId;%0A    %7D%0A%0A
+    public String getTargetDiscussionContentId() %7B%0A        return targetDiscussionContentId;%0A    %7D%0A    %0A    public int getTargetPost() %7B%0A        return targetPost;%0A    %7D%0A    %0A
     public stati
@@ -2143,26 +2143,24 @@
 rgetUserId;%0A
-//
         priv
@@ -2159,28 +2159,77 @@
     private 
-Long
+String targetDiscussionContentId;%0A        private int
  targetPostI
@@ -2227,18 +2227,16 @@
 rgetPost
-Id
 ;%0A%0A     
@@ -3586,18 +3586,16 @@
      %7D%0A%0A
-//
         
@@ -3619,19 +3619,217 @@
 rget
-PostId(Long
+DiscussionConcentId(String targetDiscussionContentId) %7B%0A            this.targetDiscussionContentId = targetDiscussionContentId;%0A            return this;%0A        %7D%0A        %0A        public Builder targetPost(int
  tar
@@ -3839,16 +3839,12 @@
 Post
-Id
 ) %7B%0A
-//
     
@@ -3866,18 +3866,16 @@
 rgetPost
-Id
  = targe
@@ -3883,14 +3883,10 @@
 Post
-Id;%0A//
+;%0A
     
@@ -3910,10 +3910,8 @@
 is;%0A
-//
     
@@ -3908,32 +3908,41 @@
 this;%0A        %7D%0A
+        %0A
         public A

Add targetDiscussionContentId and targetPost to Activity #21