package com.dxhy.common.jwt;

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

/**
 * @author jiaohongyang
 * @date 2019年3月26日 下午5:52:52
 *
 */
@SuppressWarnings("AlibabaClassNamingShouldBeCamel")
public class JWTInfo implements Serializable, IJWTInfo {
    private String username;
    private String userId;
    private String loginname;
    private String userInfo;

    public JWTInfo(String userInfo, String username, String userId, String loginname) {
        this.userInfo = userInfo;
        this.username = username;
        this.userId = userId;
        this.loginname = loginname;

    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    public String getUserName() {
        return username;
    }

    @Override
    public String getId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    @Override
    public String getLoginName() {
        return loginname;
    }

    public void setLoginname(String loginname) {
        this.loginname = loginname;
    }

    @Override
    public String getUserInfo() {
        return userInfo;
    }

    public void setUserInfo(String userInfo) {
        this.userInfo = userInfo;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        JWTInfo jwtInfo = (JWTInfo)o;

        if (!Objects.equals(username, jwtInfo.username)) {
            return false;
        }

        return Objects.equals(userId, jwtInfo.userId);

    }

    @Override
    public int hashCode() {
        int result = username != null ? username.hashCode() : 0;
        result = 31 * result + (userId != null ? userId.hashCode() : 0);
        return result;
    }

}
