package es.uv.dagarcos.master.domain;

import jakarta.persistence.*;
import java.time.Instant;

@Entity
@Table(name = "shard_lifecycle_events")
public class ShardLifecycleEvent {

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

    @Enumerated(EnumType.STRING)
    @Column(nullable = false)
    private ShardLifecycleEventType eventType;

    @Column(nullable = false)
    private Instant timestamp;

    private String details;

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Shard shard;

    protected ShardLifecycleEvent() {}

    public ShardLifecycleEvent(Shard shard,
                               ShardLifecycleEventType eventType,
                               String details) {
        this.shard = shard;
        this.eventType = eventType;
        this.details = details;
        this.timestamp = Instant.now();
    }

    public Long getId() {
        return id;
    }

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

    public ShardLifecycleEventType getEventType() {
        return eventType;
    }

    public void setEventType(ShardLifecycleEventType eventType) {
        this.eventType = eventType;
    }

    public Instant getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Instant timestamp) {
        this.timestamp = timestamp;
    }

    public String getDetails() {
        return details;
    }

    public void setDetails(String details) {
        this.details = details;
    }

    public Shard getShard() {
        return shard;
    }

    public void setShard(Shard shard) {
        this.shard = shard;
    }

    
}