package com.apobates.forum.letterbox.entity;

import javax.persistence.Transient;
import java.io.Serializable;

/**
 * ForumLetter的收件人
 *
 * @author xiaofanku
 * @since 20200510
 */
public class ForumLetterReceiver implements Serializable {
    private static final long serialVersionUID = 1L;
    private long member;
    private String memberNickname;

    public ForumLetterReceiver(){}
    public ForumLetterReceiver(long member, String memberNickname) {
        super();
        this.member = member;
        this.memberNickname = memberNickname;
    }
    
    public long getMember() {
        return member;
    }
    
    public String getMemberNickname() {
        return memberNickname;
    }

    public void setMember(long member) {
        this.member = member;
    }

    public void setMemberNickname(String memberNickname) {
        this.memberNickname = memberNickname;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + (int) (member ^ (member >>> 32));
        result = prime * result + ((memberNickname == null) ? 0 : memberNickname.hashCode());
        return result;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        ForumLetterReceiver other = (ForumLetterReceiver) obj;
        if (member != other.member) {
            return false;
        }
        if (memberNickname == null) {
            if (other.memberNickname != null) {
                return false;
            }
        } else if (!memberNickname.equals(other.memberNickname)) {
            return false;
        }
        return true;
    }
    @Transient
    public static ForumLetterReceiver allMemberes() {
        return new ForumLetterReceiver(0L, "所有");
    }
}