package de.accso.flexinale.backoffice_api_contract.api_contract.model;

import de.accso.flexinale.common.shared_kernel.EqualsByContent;
import de.accso.flexinale.common.shared_kernel.Identifiable;
import de.accso.flexinale.common.shared_kernel.RawWrapper;
import de.accso.flexinale.common.shared_kernel.Versionable;
import org.apache.commons.lang3.builder.EqualsBuilder;

import java.io.Serializable;

@SuppressWarnings("unused")
public record FilmTO(Id id, Version version,
                     Titel titel, ImdbUrl imdbUrl, DauerInMinuten dauerInMinuten)
        implements Identifiable, Versionable, EqualsByContent, Serializable
{
    public record Titel(String raw) implements RawWrapper<String> {}
    public record ImdbUrl(String raw) implements RawWrapper<String> {}
    public record DauerInMinuten(Integer raw) implements RawWrapper<Integer> {}

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

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

        final FilmTO that = (FilmTO) o;

        return new EqualsBuilder()
                .append(id, that.id)
                .append(titel, that.titel).append(imdbUrl, that.imdbUrl)
                .append(dauerInMinuten, that.dauerInMinuten).isEquals();
    }
}
