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;
020
021import javax.inject.Named;
022import javax.inject.Singleton;
023
024import java.util.function.Function;
025
026import org.eclipse.aether.RepositorySystemSession;
027import org.eclipse.aether.repository.ArtifactRepository;
028import org.eclipse.aether.util.repository.RepositoryIdHelper;
029
030/**
031 * Default local path prefix composer factory: it fully reuses {@link LocalPathPrefixComposerFactorySupport} class
032 * without changing anything from it.
033 *
034 * @since 1.8.1
035 */
036@Singleton
037@Named
038public final class DefaultLocalPathPrefixComposerFactory extends LocalPathPrefixComposerFactorySupport {
039    @Override
040    public LocalPathPrefixComposer createComposer(RepositorySystemSession session) {
041        return new DefaultLocalPathPrefixComposer(
042                isSplit(session),
043                getLocalPrefix(session),
044                isSplitLocal(session),
045                getRemotePrefix(session),
046                isSplitRemote(session),
047                isSplitRemoteRepository(session),
048                isSplitRemoteRepositoryLast(session),
049                getReleasesPrefix(session),
050                getSnapshotsPrefix(session),
051                RepositoryIdHelper.cachedIdToPathSegment(session));
052    }
053
054    /**
055     * {@link LocalPathPrefixComposer} implementation that fully reuses {@link LocalPathPrefixComposerSupport} class.
056     */
057    private static class DefaultLocalPathPrefixComposer extends LocalPathPrefixComposerSupport {
058        @SuppressWarnings("checkstyle:parameternumber")
059        private DefaultLocalPathPrefixComposer(
060                boolean split,
061                String localPrefix,
062                boolean splitLocal,
063                String remotePrefix,
064                boolean splitRemote,
065                boolean splitRemoteRepository,
066                boolean splitRemoteRepositoryLast,
067                String releasesPrefix,
068                String snapshotsPrefix,
069                Function<ArtifactRepository, String> idToPathSegmentFunction) {
070            super(
071                    split,
072                    localPrefix,
073                    splitLocal,
074                    remotePrefix,
075                    splitRemote,
076                    splitRemoteRepository,
077                    splitRemoteRepositoryLast,
078                    releasesPrefix,
079                    snapshotsPrefix,
080                    idToPathSegmentFunction);
081        }
082    }
083}