package org.raddatz.familienarchiv.document.annotation;

import jakarta.validation.Valid;
import jakarta.validation.constraints.DecimalMax;
import org.raddatz.familienarchiv.document.annotation.UniquePoints;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class CreateAnnotationDTO {
    private int pageNumber;
    private double x;
    private double y;
    private double width;
    private double height;
    private String color;

    @Size(min = 4, max = 4, message = "polygon must have exactly 4 points")
    @UniquePoints
    @Valid
    private List<@Size(min = 2, max = 2, message = "each point must have exactly 2 coordinates")
                 List<@DecimalMin("0.0") @DecimalMax("1.0") Double>> polygon;

    public CreateAnnotationDTO(int pageNumber, double x, double y, double width, double height, String color) {
        this.pageNumber = pageNumber;
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        this.color = color;
    }
}
