基本的操作
package write.object;
import java.io.Serializable;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class Employee implements Serializable{
/**
*
*/
private static final long serialVersionUID = 4676107110402915976L;
private String name;
private double salary;
private Calendar hireDay;
public Employee(String name, double salary, Calendar hireDay) {
super();
this.name = name;
this.salary = salary;
this.hireDay = hireDay;
}
public Employee(String name, double salary, int year, int month, int dayOfMonth) {
super();
this.name = name;
this.salary = salary;
Calendar calendar = new GregorianCalendar(year, month, dayOfMonth);
this.hireDay = calendar;
}
public Employee() {
super();
}
@Override
public String toString() {
return "Employee [name=" + name + ", salary=" + salary + ", hireDay=" + hireDay + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((hireDay == null) ? 0 : hireDay.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
long temp;
temp = Double.doubleToLongBits(salary);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Employee other = (Employee) obj;
if (hireDay == null) {
if (other.hireDay != null)
return false;
} else if (!hireDay.equals(other.hireDay))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (Double.doubleToLongBits(salary) != Double.doubleToLongBits(other.salary))
return false;
return true;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public Calendar getHireDay() {
return hireDay;
}
public void setHireDay(Calendar hireDay) {
this.hireDay = hireDay;
}
}