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.internal.impl.resolution;
020
021import java.util.List;
022
023import org.eclipse.aether.RepositorySystemSession;
024import org.eclipse.aether.internal.impl.DefaultArtifactResolver;
025import org.eclipse.aether.resolution.ArtifactResult;
026import org.eclipse.aether.spi.resolution.ArtifactResolverPostProcessor;
027
028/**
029 * Support class to implement {@link ArtifactResolverPostProcessor}.
030 *
031 * @since 1.9.0
032 */
033public abstract class ArtifactResolverPostProcessorSupport implements ArtifactResolverPostProcessor {
034    protected static final String CONFIG_PROPS_PREFIX = DefaultArtifactResolver.CONFIG_PROPS_PREFIX + "postProcessor.";
035
036    /**
037     * This implementation will call into underlying code only if enabled.
038     */
039    @Override
040    public void postProcess(RepositorySystemSession session, List<ArtifactResult> artifactResults) {
041        if (isEnabled(session)) {
042            doPostProcess(session, artifactResults);
043        }
044    }
045
046    protected abstract void doPostProcess(RepositorySystemSession session, List<ArtifactResult> artifactResults);
047
048    /**
049     * Returns {@code true} if session configuration marks this instance as enabled.
050     * <p>
051     * Default value is {@code false}.
052     */
053    protected abstract boolean isEnabled(RepositorySystemSession session);
054}