package com.r35157.nenjim.service.journal.valuetypes;

import java.util.Objects;

/** A scheme-qualified dependency target supported by Journal format version 1. */
public record DependencyTarget(String scheme, ArtifactCoordinate coordinate) {
    public static final String NENJIM_SCHEME = "nenjim";

    public DependencyTarget {
        Objects.requireNonNull(scheme, "scheme");
        Objects.requireNonNull(coordinate, "coordinate");
        if (!NENJIM_SCHEME.equals(scheme)) {
            throw new IllegalArgumentException("Unsupported dependency scheme: '" + scheme + "'");
        }
    }

    public static DependencyTarget nenjim(ArtifactCoordinate coordinate) {
        return new DependencyTarget(NENJIM_SCHEME, coordinate);
    }

    @Override
    public String toString() {
        return scheme + ":" + coordinate;
    }
}
