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

import javax.persistence.Column;
import javax.persistence.Entity;
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 = "id_counter")
public class IdCounter extends IdEntity<Integer> {

  @NotBlank
  @Column
  private String name;

  @NotNull
  @Column
  private Integer count;

  public IdCounter() {
  }

  public IdCounter(String name) {
    this(name, 0);
  }

  public IdCounter(String name, int length) {
    this.name = name;
    this.count = 0;
  }

  public void addOneCount() {
    this.setCount(this.getCount() + 1);
  }

  public String getName() {
    return this.name;
  }

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

  public Integer getCount() {
    return this.count;
  }

  public void setCount(Integer count) {
    this.count = count;
  }

}
