package de.accso.flexinale.backoffice.api_contract.event;

import de.accso.flexinale.backoffice.api_contract.event.model.KinoTO;
import de.accso.flexinale.common.api.event.AbstractEvent;
import de.accso.flexinale.common.api.event.Event;
import de.accso.flexinale.common.shared_kernel.DoNotCheckInArchitectureTests;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

public abstract sealed class KinoCRUDEvent extends AbstractEvent implements Event
    permits KinoCreatedEvent, KinoUpdatedEvent, KinoDeletedEvent {

    public enum CRUD { CREATE, UPDATE, DELETE }

    @DoNotCheckInArchitectureTests
    public final KinoTO kino;

    protected KinoCRUDEvent(final KinoTO kino) {
        this.kino = kino;
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o) {return true;}

        if (o == null || getClass() != o.getClass()) {return false;}

        final KinoCRUDEvent that = (KinoCRUDEvent) o;

        return new EqualsBuilder().appendSuper(super.equals(o))
                .append(version(), that.version())
                .append(kino, that.kino).isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37)
                .appendSuper(super.hashCode()).append(kino)
                .append(version())
                .toHashCode();
    }
}
