package xyz.wbsite.frame.auth;

import xyz.wbsite.frame.utils.IDgenerator;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
 * Token - 通行证类
 *
 * @author wangbing
 * @version 0.0.1
 * @since 2017-01-01
 */
public class  Token implements Serializable {
    private static final Long serialVersionUID = 1L;
    /**
     * ID
     */
    private long id;
    /**
     * TOKEN
     */
    private String token;
    /**
     * 用户ID
     */
    private long userId;
    /**
     * 用户名称
     */
    private String userName;

    private Set<String> resSet = new HashSet<>();

    public boolean hasRes(String res) {
        for (String s : resSet) {
            if (res.matches(s)) {
                return true;
            }
        }

        return false;
    }

    public void putRes(String resource) {
        resSet.add(resource);
    }

    public void putRes(Set<String> resourceSet) {
        this.resSet.addAll(resourceSet);
    }


    public Set<String> getResSet() {
        return resSet;
    }


    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getUserId() {
        return userId;
    }

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

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }
}
