package J20250802.demo04;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author WanJl
 * @version 1.0
 * @title Person
 * @description
 * @create 2025/8/2
 */
public class Person implements Serializable,Comparable<Person> {
    private String name;
    private Integer age;
    private String sex;
    private String phone;
    private String idNumber;

    public Person() {
    }

    public Person(String name, Integer age, String sex, String phone, String idNumber) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.phone = phone;
        this.idNumber = idNumber;
    }

    public String getName() {
        return name;
    }

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

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getIdNumber() {
        return idNumber;
    }

    public void setIdNumber(String idNumber) {
        this.idNumber = idNumber;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return Objects.equals(name, person.name) && Objects.equals(age, person.age) && Objects.equals(sex, person.sex) && Objects.equals(phone, person.phone) && Objects.equals(idNumber, person.idNumber);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, sex, phone, idNumber);
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                ", phone='" + phone + '\'' +
                ", idNumber='" + idNumber + '\'' +
                '}';
    }

    @Override
    public int compareTo(Person o) {
        int r=-1;
        r=this.getIdNumber().compareTo(o.getIdNumber())==0
                ?this.getName().compareTo(o.getName())
                :r;
        return r;
    }
}
