1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.eclipse.aether.internal.impl;
20
21 import javax.inject.Named;
22 import javax.inject.Singleton;
23
24 import java.util.function.Function;
25
26 import org.eclipse.aether.RepositorySystemSession;
27 import org.eclipse.aether.repository.ArtifactRepository;
28 import org.eclipse.aether.util.repository.RepositoryIdHelper;
29
30 /**
31 * Default local path prefix composer factory: it fully reuses {@link LocalPathPrefixComposerFactorySupport} class
32 * without changing anything from it.
33 *
34 * @since 1.8.1
35 */
36 @Singleton
37 @Named
38 public final class DefaultLocalPathPrefixComposerFactory extends LocalPathPrefixComposerFactorySupport {
39 @Override
40 public LocalPathPrefixComposer createComposer(RepositorySystemSession session) {
41 return new DefaultLocalPathPrefixComposer(
42 isSplit(session),
43 getLocalPrefix(session),
44 isSplitLocal(session),
45 getRemotePrefix(session),
46 isSplitRemote(session),
47 isSplitRemoteRepository(session),
48 isSplitRemoteRepositoryLast(session),
49 getReleasesPrefix(session),
50 getSnapshotsPrefix(session),
51 RepositoryIdHelper.cachedIdToPathSegment(session));
52 }
53
54 /**
55 * {@link LocalPathPrefixComposer} implementation that fully reuses {@link LocalPathPrefixComposerSupport} class.
56 */
57 private static class DefaultLocalPathPrefixComposer extends LocalPathPrefixComposerSupport {
58 @SuppressWarnings("checkstyle:parameternumber")
59 private DefaultLocalPathPrefixComposer(
60 boolean split,
61 String localPrefix,
62 boolean splitLocal,
63 String remotePrefix,
64 boolean splitRemote,
65 boolean splitRemoteRepository,
66 boolean splitRemoteRepositoryLast,
67 String releasesPrefix,
68 String snapshotsPrefix,
69 Function<ArtifactRepository, String> idToPathSegmentFunction) {
70 super(
71 split,
72 localPrefix,
73 splitLocal,
74 remotePrefix,
75 splitRemote,
76 splitRemoteRepository,
77 splitRemoteRepositoryLast,
78 releasesPrefix,
79 snapshotsPrefix,
80 idToPathSegmentFunction);
81 }
82 }
83 }