package marketing.heyday.hartmann.fotodocumentation.core.model;

import java.util.Date;

import org.apache.commons.lang.builder.HashCodeBuilder;

import jakarta.persistence.*;

/**
 * 
 * 
 * <p>Copyright: Copyright (c) 2024</p>
 * <p>Company: heyday Marketing GmbH</p>
 * @author <a href="mailto:p.verboom@heyday.marketing">Patrick Verboom</a>
 * @version 1.0
 * 
 * created: 19 Jan 2026
 */

@Entity
@Table(name = "picture")
public class Picture extends AbstractDateEntity {
	private static final long serialVersionUID = 1L;
	public static final String SEQUENCE = "picture_seq";

	@Id
	@Column(name = "picture_id", length = 22)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SEQUENCE)
	@SequenceGenerator(name = SEQUENCE, sequenceName = SEQUENCE, allocationSize = 1)
	private Long pictureId;

	// username from the person that shot the picture
	@Column(name = "username")
	private String username;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "picture_date", nullable = false)
	private Date pictureDate;

	@Basic(fetch = FetchType.LAZY)
	private String comment;
	
	
	private String category;

	@Column(name = "image")
	@Basic(fetch = FetchType.LAZY)
	private String image;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "customer_id_fk")
	private Customer customer;

	public Long getPictureId() {
		return pictureId;
	}

	public void setPictureId(Long pictureId) {
		this.pictureId = pictureId;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public Date getPictureDate() {
		return pictureDate;
	}

	public void setPictureDate(Date pictureDate) {
		this.pictureDate = pictureDate;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}
	
	

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(pictureId).toHashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null || this.getClass() != obj.getClass() || pictureId == null) {
			return false;
		}
		return this.pictureId.equals(((Picture) obj).getPictureId());
	}

	public static class Builder {
		private Picture instance = new Picture();

		public Builder username(String username) {
			instance.setUsername(username);
			return this;
		}

		public Builder pictureDate(Date pictureDate) {
			instance.setPictureDate(pictureDate);
			return this;
		}
		
		public Builder comment(String comment) {
			instance.setComment(comment);
			return this;
		}

		public Builder category(String category) {
			instance.setCategory(category);
			return this;
		}

		public Builder image(String image) {
			instance.setImage(image);
			return this;
		}
		
		public Builder customer(Customer customer) {
			instance.setCustomer(customer);
			return this;
		}

		public Picture build() {
			return instance;
		}
	}
}
