package com.acme.model.domain.ad.entity;


import com.acme.structure.BaseEntity;
import com.acme.structure.BaseEntityListener;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity(name = "Unit")
@Table(name = "UNITS")
//this is for oracle db @SequenceGenerator(name = "UNIT_SEQ", sequenceName = "UNIT_SEQ", allocationSize = 1)
@EntityListeners( { BaseEntityListener.class })
public class Unit extends BaseEntity
{
    private String code;
    private String name;
    private boolean baseUnit;

    public Unit()
    {
        entityName = "Unit";
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO) //, this is for oracle db, generator = "UNIT_SEQ")
    @Column(name = "ID")
    public int getId()
    {
        return id;
    }

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

    @Column(name = "CODE", length = 8)
    public String getCode()
    {
        return code;
    }

    public void setCode(String code)
    {
        this.code = code;
    }

    @Column(name = "NAME", length = 20)
    public String getName()
    {
        return name;
    }

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

    @Column(name = "ISBASEUNIT")
    public boolean isBaseUnit()
    {
        return baseUnit;
    }

    public void setBaseUnit(boolean baseUnit)
    {
        this.baseUnit = baseUnit;
    }

    @Override
    public String toString()
    {
        return getCode();
        // return getCode() + "(" + getName() + ")";
    }

}
