package com.hmsoft.model;

import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

import javafx.beans.property.IntegerProperty;
import javafx.beans.property.LongProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

/**
 * 
 * @author zq
 *
 */
public class Batch implements Serializable {

	private static final long serialVersionUID = 9138363630377951422L;

	private LongProperty batchId;
	private StringProperty batchNo;
	private IntegerProperty status;//状态(新建-0、已导入-1、已发布-2)
	private StringProperty statusDes;
	private StringProperty createTime;//创建时间
	private StringProperty publishTime;//发布时间
	private StringProperty batchDesc;//描述
	
	public Batch() {
		this.batchId = new SimpleLongProperty();
		this.batchNo = new SimpleStringProperty();
		this.status = new SimpleIntegerProperty();
		this.statusDes = new SimpleStringProperty();
		this.createTime = new SimpleStringProperty();
		this.publishTime = new SimpleStringProperty();
		this.batchDesc = new SimpleStringProperty();
	}
	
	public Long getBatchId() {
		return batchId.get();
	}

	public String getBatchNo() {
		return batchNo.get();
	}

	public Integer getStatus() {
		return status.get();
	}

	public String getStatusDes() {
		return statusDes.get();
	}

	public String getCreateTime() {
		return createTime.get();
	}

	public String getPublishTime() {
		return publishTime.get();
	}

	public void setBatchId(Long batchId) {
		this.batchId.set(batchId);
	}

	public void setBatchNo(String batchNo) {
		this.batchNo.set(batchNo);
	}

	public void setStatus(Integer status) {
		this.status.set(status);
	}

	public void setStatusDes(String statusDes) {
		this.statusDes.set(statusDes);
	}

	public void setCreateTime(String createTime) {
		this.createTime.set(createTime);
	}

	public void setPublishTime(String publishTime) {
		this.publishTime.set(publishTime);
	}

	public String getBatchDesc() {
		return batchDesc.get();
	}

	public void setBatchDesc(String batchDesc) {
		this.batchDesc.set(batchDesc);;
	}

	public String toString() {
		return new StringBuilder()
				.append(batchId.get()).append(" | ")
				.append(batchNo.get()).append(" | ")
				.append(status.get() == 0 ? "新建" : (status.get() == 1 ? "已导入" : "已发布"))
				.toString();
	}
	
	public int hashCode() {
	     return new HashCodeBuilder(17, 37).
	       append(this.batchId.get()).
	       append(this.batchNo.get()).
	       append(this.status.get()).
	       append(this.createTime.get()).
	       toHashCode();
	}
	
	public boolean equals(Object obj) {
		   if (obj == null) { return false; }
		   if (obj == this) { return true; }
		   if (obj.getClass() != getClass()) {
		     return false;
		   }
		   Batch oth = (Batch) obj;
		   return new EqualsBuilder()
		                 .append(this.batchId.get(), oth.batchId.get())
		                 .append(this.batchNo.get(), oth.batchNo.get())
		                 .append(this.status.get(), oth.status.get())
		                 .append(this.createTime.get(), oth.createTime.get())
		                 .isEquals();
	}
	
}
