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 School implements Serializable {

	private static final long serialVersionUID = -9178032507946351789L;
	
	private LongProperty schoolId;
	private StringProperty schoolName;
	
	//目前学校和账号一对一!
	private StringProperty userName;
	private StringProperty passWord;
	
	public School() {
		this.schoolId =  new SimpleLongProperty();
		this.schoolName = new SimpleStringProperty();
		this.userName = new SimpleStringProperty();
		this.passWord = new SimpleStringProperty();
	}
	
	public School(int schooId, String schoolName, String userName, String passWord) {
		this.schoolId =  new SimpleLongProperty(schooId);
		this.schoolName = new SimpleStringProperty(schoolName);
		this.userName = new SimpleStringProperty(userName);
		this.passWord = new SimpleStringProperty(passWord);
	}
	
	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 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();
	}
}
