View Javadoc
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.synccontext.named;
20  
21  /**
22   * As end-user "mappers" are actually configurations/compositions and are constructed from several NameMapper
23   * implementations, this helper class constructing them. This class also holds "names" used by service locator and
24   * Guice/Sisu as well. Ideally, name mapper you want should exist here, constructing name mappers should not be
25   * needed (unless some very specific case or testing).
26   *
27   * @since 1.9.4
28   */
29  public final class NameMappers {
30      private NameMappers() {}
31  
32      public static final String STATIC_NAME = "static";
33  
34      public static final String GAV_NAME = "gav";
35  
36      public static final String FILE_GAV_NAME = "file-gav";
37  
38      public static final String FILE_HGAV_NAME = "file-hgav";
39  
40      /**
41       * @since 1.9.25
42       */
43      public static final String GAECV_NAME = "gaecv";
44  
45      /**
46       * @since 1.9.25
47       */
48      public static final String FILE_GAECV_NAME = "file-gaecv";
49  
50      /**
51       * @since 1.9.25
52       */
53      public static final String FILE_HGAECV_NAME = "file-hgaecv";
54  
55      /**
56       * @since 1.9.6
57       */
58      public static final String FILE_STATIC_NAME = "file-static";
59  
60      public static final String DISCRIMINATING_NAME = "discriminating";
61  
62      public static NameMapper staticNameMapper() {
63          return new StaticNameMapper();
64      }
65  
66      public static NameMapper gavNameMapper() {
67          return gavNameMapper(false);
68      }
69  
70      /**
71       * @since 1.9.25
72       */
73      public static NameMapper gavNameMapper(boolean fileSystemFriendly) {
74          if (fileSystemFriendly) {
75              return new GAVNameMapper(true, "artifact~", ".lock", "metadata~", ".lock", "~");
76          } else {
77              return new GAVNameMapper(false, "artifact:", "", "metadata:", "", ":");
78          }
79      }
80  
81      /**
82       * @since 1.9.25
83       */
84      public static NameMapper gaecvNameMapper() {
85          return gaecvNameMapper(false);
86      }
87  
88      /**
89       * @since 1.9.25
90       */
91      public static NameMapper gaecvNameMapper(boolean fileSystemFriendly) {
92          if (fileSystemFriendly) {
93              return new GAECVNameMapper(true, "artifact~", ".lock", "metadata~", ".lock", "~");
94          } else {
95              return new GAECVNameMapper(false, "artifact:", "", "metadata:", "", ":");
96          }
97      }
98  
99      public static NameMapper fileGavNameMapper() {
100         return new BasedirNameMapper(gavNameMapper(true));
101     }
102 
103     /**
104      * @since 1.9.25
105      */
106     public static NameMapper fileGaecvNameMapper() {
107         return new BasedirNameMapper(gaecvNameMapper(true));
108     }
109 
110     /**
111      * @since 1.9.6
112      */
113     public static NameMapper fileStaticNameMapper() {
114         return new BasedirNameMapper(new StaticNameMapper());
115     }
116 
117     public static NameMapper fileHashingGavNameMapper() {
118         return new BasedirNameMapper(new HashingNameMapper(gavNameMapper(false)));
119     }
120 
121     /**
122      * @since 1.9.25
123      */
124     public static NameMapper fileHashingGaecvNameMapper() {
125         return new BasedirNameMapper(new HashingNameMapper(gaecvNameMapper(false)));
126     }
127 
128     public static NameMapper discriminatingNameMapper() {
129         return new DiscriminatingNameMapper(gavNameMapper(false));
130     }
131 }