package de.avatic.taricdb.model;

import java.time.LocalDate;
import java.util.HashSet;
import java.util.Set;

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

import jakarta.validation.constraints.Size;


@Table("additional_code")
public class AdditionalCode {

	@Id
    private Integer id;

    @Size(max = 4)
    private String additionalCode;

    private LocalDate startDate;

    private LocalDate endDate;
    
    @MappedCollection(idColumn = "ref_id")
    private Set<AdditionalCodeDesc> desc;
    
    public AdditionalCode(String additionalCode, LocalDate startDate, LocalDate endDate) {
    	this.desc = new HashSet<>();
    	this.additionalCode = additionalCode;
    	this.startDate = startDate;
    	this.endDate = endDate;
    }

    public Integer getId() {
        return id;
    }

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

    public String getAdditionalCode() {
        return additionalCode;
    }

    public void setAdditionalCode(final String additionalCode) {
        this.additionalCode = additionalCode;
    }

    public LocalDate getStartDate() {
        return startDate;
    }

    public void setStartDate(final LocalDate startDate) {
        this.startDate = startDate;
    }

    public LocalDate getEndDate() {
        return endDate;
    }

    public void setEndDate(final LocalDate endDate) {
        this.endDate = endDate;
    }
    
	public Set<AdditionalCodeDesc> getDesc() {
		return desc;
	}
	
	public void addDesc(AdditionalCodeDesc desc) {
		this.desc.add(desc);
	}

}
