package J20250722;

import java.util.Objects;

/**
 * @author WanJl
 * @version 1.0
 * @title Teacher
 * @description
 * @create 2025/7/22
 */
public class Teacher implements Comparable<Teacher>{
    private Integer id;
    private String name;

    public Teacher() {
    }

    public Teacher(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Teacher teacher = (Teacher) o;
        return Objects.equals(id, teacher.id) && Objects.equals(name, teacher.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name);
    }

    @Override
    public String toString() {
        return "Teacher{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }
    //按照ID从小到大排序
    @Override
    public int compareTo(Teacher o) {
        int result=this.getId()-o.getId();
        result=result==0?this.getName().compareTo(o.getName()):result;
        return result;
    }
}
