Newer
Older
CosmosServer / src / main / java / com / example / cosmos_serversb / entities / User.java
package com.example.cosmos_serversb.entities;

import java.util.HashSet;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
import lombok.Data;
import com.example.cosmos_serversb.views.UsersView;


public class User {
    /**
     * USER用のクラス
     *
     * @param uId string //LONGに変更
     * @param uri String
     * @param name String
     * @param iconUri String iconの保存先
     * @param login Boolean トークンが存在するか否か
     * @param groups Set<Group> 所属するグループ
     * @param tokens Set<Token> 所持するトークン
     * @param firstToken String 初期トークン
     * <p>
     * TODO: Tokenのデータベース接続
     * TODO: ダミートークン削除
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("token")
    public String firstToken;//初期トークン
    @JsonView(UsersView.putUsersView.class)
    public String uId;
    @JsonView(UsersView.putUsersView.class)
    public String uri;
    @JsonView(UsersView.getUsersView.class)
    public String name;
    @JsonView(UsersView.getUsersView.class)
    public String iconUri;
    @JsonIgnore

    public boolean login = true;
    public Set<Group> groups = new HashSet<>();//HashSetでいいのかな?
    //仕様ではStringを返すため
    //public Set<Token> tokens = new HashSet<>();
    //public Set<String> tokens = new HashSet<>();
    public String token;
    private String dummyToken = "a9965652-c2ec-4a0d-a78a-b457e8b2deca";

    public User() {

    }

    public User(String name, String uId, String uri, String iconUri) {
        setuId(uId);
        setUri(uri);
        setName(name);
        setIconUri(iconUri);
        setToken(this.dummyToken);
        //addToken(this.dummyToken);
        this.login = true;
    }


    public String getuId() {
        return uId;
    }

    public void setuId(String uId) {
        this.uId = uId;
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIconUri() {
        return iconUri;
    }

    public void setIconUri(String iconUri) {
        this.iconUri = iconUri;
    }

    public String getToken() {
        return firstToken;
    }

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

    public Set<Group> getGroups() {
        return groups;
    }

    public void setGroups(Set<Group> groups) {
        this.groups = groups;
    }

    public void addGroups(Group group) {
        groups.add(group);
    }
}