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.LongProperty;
import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

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

	private static final long serialVersionUID = -9178032507946351789L;
	private LongProperty id;  //序号
	private LongProperty schoolId;  //学校序号
	private StringProperty schoolName;
	//目前学校和账号一对一!
	private StringProperty userName;
	private StringProperty passWord;
	//连接状态,不用序列化
	private transient StringProperty statusDesc;//(已连接，未连接，已断开)
	private transient StringProperty connectedTime;//开始连接时间
	private transient StringProperty disconnectTime;//断开连接时间
	
	public School() {
		this.id = new SimpleLongProperty();
		this.schoolId =  new SimpleLongProperty();
		this.schoolName = new SimpleStringProperty();
		this.userName = new SimpleStringProperty();
		this.passWord = new SimpleStringProperty();
		this.statusDesc = new SimpleStringProperty();
		this.connectedTime = new SimpleStringProperty();
		this.disconnectTime = new SimpleStringProperty();
	}
	
	public School(Long schooId, String schoolName) {
		this.schoolId =  new SimpleLongProperty(schooId);
		this.schoolName = new SimpleStringProperty(schoolName);
	}
	
	public School(int id,int schooId, String schoolName, String userName, String passWord) {
		this.id = new SimpleLongProperty(id);
		this.schoolId =  new SimpleLongProperty(schooId);
		this.schoolName = new SimpleStringProperty(schoolName);
		this.userName = new SimpleStringProperty(userName);
		this.passWord = new SimpleStringProperty(passWord);
	}
	
	public Long getId() {
		return id.get();
	}
	public void setId(Long id) {
		this.id.set(id);
	}
	
	public Long getSchoolId() {
		return schoolId.get();
	}
	public void setSchoolId(Long schoolId) {
		this.schoolId.set(schoolId);
	}
	public String getSchoolName() {
		return schoolName.get();
	}
	public void setSchoolName(String schoolName) {
		this.schoolName.set(schoolName);
	}
	
	public String getUserName() {
		return userName.get();
	}
	public String getPassWord() {
		return passWord.get();
	}
	public void setUserName(String userName) {
		this.userName.set(userName);
	}
	public void setPassWord(String passWord) {
		this.passWord.set(passWord);
	}
	public String getStatusDesc() {
		return statusDesc.get();
	}
	public void setStatusDesc(String statusDesc) {
		this.statusDesc.set(statusDesc);
	}

	public String getConnectedTime() {
		return connectedTime.get();
	}

	public String getDisconnectTime() {
		return disconnectTime.get();
	}

	public void setConnectedTime(String connectedTime) {
		this.connectedTime.set(connectedTime);
	}

	public void setDisconnectTime(String disconnectTime) {
		this.disconnectTime.set(disconnectTime);
	}

	public String toString() {
		return new StringBuilder().append(schoolId.get()).append(" | ").append(schoolName.get()).toString();
	}
	
	public int hashCode() {
	     return new HashCodeBuilder(17, 37).
	       append(this.schoolId.get()).
	       append(this.schoolName.get()).
	       toHashCode();
	}
	
	public boolean equals(Object obj) {
		   if (obj == null) { return false; }
		   if (obj == this) { return true; }
		   if (obj.getClass() != getClass()) {
		     return false;
		   }
		   School oth = (School) obj;
		   return new EqualsBuilder()
		                 .append(this.schoolId.get(), oth.schoolId.get())
		                 .append(this.schoolName.get(), oth.schoolName.get())
		                 .isEquals();
	}
}
