SocialUserResponse.java 2.25 KB
package com.yohomars.search.model;

import com.yoho.tools.common.beans.BaseBean;
import org.apache.commons.collections.CollectionUtils;

import java.util.*;

/**
 * @author gris.wang
 * @since 2018/2/23
 **/
public class SocialUserResponse extends BaseBean {

    private Integer rule;

    private Integer page;

    private Set<User> users;

    public Integer getRule() {
        return rule;
    }

    public void setRule(Integer rule) {
        this.rule = rule;
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Set<User> getUsers() {
        return users;
    }

    public void setUsers(Set<User> users) {
        this.users = users;
    }

    public void addUsers(Collection<User> users){
        if(CollectionUtils.isEmpty(this.users)){
            this.users = new HashSet<>();
        }
        this.users.addAll(users);
    }

    public static class User{
        private Integer uid;

        private String nickName;

        private String headPic;

        public Integer getUid() {
            return uid;
        }

        public void setUid(Integer uid) {
            this.uid = uid;
        }

        public String getNickName() {
            return nickName;
        }

        public void setNickName(String nickName) {
            this.nickName = nickName;
        }

        public String getHeadPic() {
            return headPic;
        }

        public void setHeadPic(String headPic) {
            this.headPic = headPic;
        }

        @Override
        public boolean equals(Object obj) {
            if(!(obj instanceof User)){
                return false;
            }
            if(obj == this){
                return true;
            }
            User that = (User)obj;
            return that.getUid().equals(this.getUid())
                    && that.getNickName().equals(this.getNickName())
                    && that.getHeadPic().equals(this.getHeadPic());
        }

        @Override
        public int hashCode() {
            int hash = 17;
            hash = hash * 31 + getNickName().hashCode();
            hash = hash * 31 + getHeadPic().hashCode();
            hash = hash * 31 + getUid();
            return hash;
        }
    }
}