content: /**
   * 
   */
  package com.anilallewar.microservices.comments.dtos;
  
  import java.io.IOException;
  import java.util.Date;
  
  import com.fasterxml.jackson.core.JsonGenerator;
  import com.fasterxml.jackson.core.JsonProcessingException;
  import com.fasterxml.jackson.databind.JsonSerializer;
  import com.fasterxml.jackson.databind.SerializerProvider;
  import com.fasterxml.jackson.databind.annotation.JsonSerialize;
  
  /**
   * Represents comments on Task.
   *
   * @author anilallewar
   */
  public class CommentDTO {
  
  	/** The task id. */
  	private String taskId;
  
  	/** The last name. */
  	private String comment;
  
  	/** The completed. */
  	private Date posted;
  
  	/**
  	 * Instantiates a new task dto.
  	 */
  	public CommentDTO() {
  		super();
  
  	}
  
  	/**
  	 * Instantiates a new task dto.
  	 *
  	 * @param taskId
  	 *            the task id
  	 * @param description
  	 *            the description
  	 */
  	public CommentDTO(String taskId, String comment, Date posted) {
  		super();
  		this.taskId = taskId;
  		this.comment = comment;
  		this.posted = posted;
  	}
  
  	/**
  	 * @return the taskId
  	 */
  	public String getTaskId() {
  		return taskId;
  	}
  
  	/**
  	 * @param taskId
  	 *            the taskId to set
  	 */
  	public void setTaskId(String taskId) {
  		this.taskId = taskId;
  	}
  
  	/**
  	 * @return the comment
  	 */
  	public String getComment() {
  		return comment;
  	}
  
  	/**
  	 * @param comment
  	 *            the comment to set
  	 */
  	public void setComment(String comment) {
  		this.comment = comment;
  	}
  
  	/**
  	 * @return the posted
  	 */
  	@JsonSerialize(using = CustomDateToLongSerializer.class)
  	public Date getPosted() {
  		return posted;
  	}
  
  	/**
  	 * @param posted
  	 *            the posted to set
  	 */
  	public void setPosted(Date posted) {
  		this.posted = posted;
  	}
  
  	/*
  	 * (non-Javadoc)
  	 * 
  	 * @see java.lang.Object#hashCode()
  	 */
  	@Override
  	public int hashCode() {
  		final int prime = 31;
  		int result = 1;
  		result = prime * result + ((comment == null) ? 0 : comment.hashCode());
  		result = prime * result + ((posted == null) ? 0 : posted.hashCode());
  		result = prime * result + ((taskId == null) ? 0 : taskId.hashCode());
  		return result;
  	}
  
  	/*
  	 * (non-Javadoc)
  	 * 
  	 * @see java.lang.Object#equals(java.lang.Object)
  	 */
  	@Override
  	public boolean equals(Object obj) {
  		if (this == obj)
  			return true;
  		if (obj == null)
  			return false;
  		if (getClass() != obj.getClass())
  			return false;
  		CommentDTO other = (CommentDTO) obj;
  		if (comment == null) {
  			if (other.comment != null)
  				return false;
  		} else if (!comment.equals(other.comment))
  			return false;
  		if (posted == null) {
  			if (other.posted != null)
  				return false;
  		} else if (!posted.equals(other.posted))
  			return false;
  		if (taskId == null) {
  			if (other.taskId != null)
  				return false;
  		} else if (!taskId.equals(other.taskId))
  			return false;
  		return true;
  	}
  
  	/*
  	 * (non-Javadoc)
  	 * 
  	 * @see java.lang.Object#toString()
  	 */
  	@Override
  	public String toString() {
  		return "CommentDTO [taskId=" + taskId + ", comment=" + comment + ", posted=" + posted + "]";
  	}
  
  }
  
  /**
   * Custom date serializer that converts the date to long before sending it out
   * 
   * @author anilallewar
   *
   */
  class CustomDateToLongSerializer extends JsonSerializer<Date> {
  
  	@Override
  	public void serialize(Date value, JsonGenerator jgen, SerializerProvider provider)
  			throws IOException, JsonProcessingException {
  		jgen.writeNumber(value.getTime());
  	}
  }