package com.ffii.core.common.mobile.entity;

import java.time.LocalDateTime;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import com.ffii.core.entity.IdEntity;

/** @author Fung */
@Entity
@Table(name = "access_token")
public class AccessToken extends IdEntity<Integer> {

  @NotBlank
  @Column
  private String username;

  @NotBlank
  @Column
  private String deviceId;

  @NotBlank
  @Column
  private String accessToken;

  @NotNull
  @Column(updatable = false)
  private LocalDateTime created;

  public AccessToken() {
  }

  public AccessToken(String username, String deviceId, String accessToken) {
    this.username = username;
    this.deviceId = deviceId;
    this.accessToken = accessToken;
  }

  @PrePersist
  public void autoSetCreated() {
    this.created = LocalDateTime.now();
  }

  public String getUsername() {
    return this.username;
  }

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

  public String getDeviceId() {
    return this.deviceId;
  }

  public void setDeviceId(String deviceId) {
    this.deviceId = deviceId;
  }

  public String getAccessToken() {
    return this.accessToken;
  }

  public void setAccessToken(String accessToken) {
    this.accessToken = accessToken;
  }

  public LocalDateTime getCreated() {
    return this.created;
  }

  public void setCreated(LocalDateTime created) {
    this.created = created;
  }

}
