package com.example.demo.entity;

import jakarta.persistence.*;
import jakarta.validation.constraints.Size;
import lombok.EqualsAndHashCode;

@Entity
@Table(name = "steps")
public class Step {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;

	@Column(name = "step_number", nullable = false)
	private Integer stepNumber;

	@Column(name = "instruction", nullable = false, columnDefinition = "TEXT")
	@Size(max = 500, message = "Instruction cannot be longer than 500 characters")
	private String instruction;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "recipe_id", nullable = false)
	@EqualsAndHashCode.Include
	private Recipe recipe;

	public Step() {
	}

	public Step(Recipe recipe, Integer stepNumber, String instruction) {
		this.recipe = recipe;
		this.stepNumber = stepNumber;
		this.instruction = instruction;
	}

	// Getters and setters
	public Integer getId() {
		return id;
	}

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

	public Recipe getRecipe() {
		return recipe;
	}

	public void setRecipe(Recipe recipe) {
		this.recipe = recipe;
	}

	public Integer getStepNumber() {
		return stepNumber;
	}

	public void setStepNumber(Integer stepNumber) {
		this.stepNumber = stepNumber;
	}

	public String getInstruction() {
		return instruction;
	}

	public void setInstruction(String instruction) {
		this.instruction = instruction;
	}
}