package de.avatic.taricdb.model;

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

import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.MappedCollection;

import jakarta.validation.constraints.Size;


public class Unit {
	
	@Id
    private Integer id;

    @Size(max = 3)
    private String unitCode;

    @Size(max = 1)
    private String unitQualifier;

    private String label;
    
    @MappedCollection(idColumn = "ref_id")
    private Set<UnitDesc> unitDesc;

    public Unit(String unitCode, String unitQualifier, String label) {
		this.unitCode = unitCode;
		this.unitQualifier = unitQualifier;
		this.label = label;
		this.unitDesc = new HashSet<>();
	}

	public Integer getId() {
        return id;
    }

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

    public String getUnitCode() {
        return unitCode;
    }

    public void setUnitCode(final String unitCode) {
        this.unitCode = unitCode;
    }

    public String getUnitQualifier() {
        return unitQualifier;
    }

    public void setUnitQualifier(final String unitQualifier) {
        this.unitQualifier = unitQualifier;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(final String label) {
        this.label = label;
    }
    
	public void addUnitDesc(UnitDesc desc) {
		unitDesc.add(desc);
	}

}
