package dev.photosync.core.provider;

import java.util.Optional;

/**
 * Which slice of the backend we are talking about: one album, or the whole
 * library.
 *
 * <p>Both browsing and uploading take one of these, and "no album configured"
 * is a first-class case rather than a null id sprinkled through the code.
 */
public record AlbumRef(Optional<String> id) {

    public AlbumRef {
        id = id == null ? Optional.empty() : id.filter(value -> !value.isBlank());
    }

    public static AlbumRef library() {
        return new AlbumRef(Optional.empty());
    }

    public static AlbumRef of(String albumId) {
        return new AlbumRef(Optional.ofNullable(albumId));
    }

    public boolean isLibrary() {
        return id.isEmpty();
    }
}
