001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.eclipse.aether.spi.validator;
020
021import org.eclipse.aether.artifact.Artifact;
022import org.eclipse.aether.graph.Dependency;
023import org.eclipse.aether.metadata.Metadata;
024import org.eclipse.aether.repository.LocalRepository;
025import org.eclipse.aether.repository.RemoteRepository;
026
027/**
028 * A repository system main input validator; this validator is used in repository system "main entry methods".
029 *
030 * @since 2.0.8
031 */
032public interface Validator {
033    /**
034     * Validates artifact.
035     *
036     * @param artifact the artifact to validate, never {@code null}.
037     * @throws IllegalArgumentException if artifact is invalid.
038     */
039    default void validateArtifact(Artifact artifact) throws IllegalArgumentException {}
040
041    /**
042     * Validates metadata.
043     *
044     * @param metadata the metadata to validate, never {@code null}.
045     * @throws IllegalArgumentException if metadata is invalid.
046     */
047    default void validateMetadata(Metadata metadata) throws IllegalArgumentException {}
048
049    /**
050     * Validates dependency.
051     *
052     * @param dependency the dependency to validate, never {@code null}.
053     * @throws IllegalArgumentException if dependency is invalid.
054     */
055    default void validateDependency(Dependency dependency) throws IllegalArgumentException {}
056
057    /**
058     * Validates managed dependency.
059     * <em>Important:</em> They are declarative constraints (version/scope/exclusion overrides) that only take effect
060     * when a matching dependency is encountered during collection. Validating them eagerly may reject valid builds
061     * where a BOM imports managed dependencies with uninterpolated property expressions (e.g. {@code ${osgi.version}})
062     * that are never actually used. If a managed dependency IS matched and its coordinates are invalid, the error
063     * will surface naturally during version resolution or artifact resolution.
064     *
065     * @param managedDependency the managed dependency to validate, never {@code null}.
066     * @throws IllegalArgumentException if dependency is invalid.
067     * @since 2.0.22
068     */
069    default void validateManagedDependency(Dependency managedDependency) throws IllegalArgumentException {}
070
071    /**
072     * Validates local repository.
073     *
074     * @param localRepository the local repository to validate, never {@code null}.
075     * @throws IllegalArgumentException if local repository is invalid.
076     */
077    default void validateLocalRepository(LocalRepository localRepository) throws IllegalArgumentException {}
078
079    /**
080     * Validates remote repository.
081     *
082     * @param remoteRepository the remote repository to validate, never {@code null}.
083     * @throws IllegalArgumentException if remote repository is invalid.
084     */
085    default void validateRemoteRepository(RemoteRepository remoteRepository) throws IllegalArgumentException {}
086}