package dev.photosync.core.provider;

import java.util.Locale;
import java.util.Objects;

/**
 * Stable key for one backend implementation, for example {@code immich}.
 *
 * <p>This value is written to the config file, so it must not change once a
 * version has shipped.
 */
public record ProviderId(String key) implements Comparable<ProviderId> {

    public ProviderId {
        Objects.requireNonNull(key, "key");
        key = key.trim().toLowerCase(Locale.ROOT);
        if (key.isEmpty()) {
            throw new IllegalArgumentException("A provider id must not be blank");
        }
    }

    @Override
    public int compareTo(ProviderId other) {
        return key.compareTo(other.key);
    }

    @Override
    public String toString() {
        return key;
    }
}
