package cn.axzo.msg.center.service.dto;

import cn.axzo.msg.center.service.enums.IdentityTypeEnum;
import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

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

/**
 * @description
 *
 * @author cold_blade
 * @date 2023/9/23
 * @version 1.0
 */
@Setter
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class IdentityDTO implements Serializable {

    private static final long serialVersionUID = 7176145314439312573L;

    /**
     * 身份id
     */
    private Long id;
    /**
     * 身份类型
     */
    private IdentityTypeEnum type;

    public boolean isValid() {
        return Objects.nonNull(id) && Objects.nonNull(type);
    }

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

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

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
