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.synccontext.named; 020 021/** 022 * As end-user "mappers" are actually configurations/compositions and are constructed from several NameMapper 023 * implementations, this helper class constructing them. This class also holds "names" used by service locator and 024 * Guice/Sisu as well. Ideally, name mapper you want should exist here, constructing name mappers should not be 025 * needed (unless some very specific case or testing). 026 * 027 * @since 1.9.4 028 */ 029public final class NameMappers { 030 private NameMappers() {} 031 032 public static final String STATIC_NAME = "static"; 033 034 public static final String GAV_NAME = "gav"; 035 036 public static final String FILE_GAV_NAME = "file-gav"; 037 038 public static final String FILE_HGAV_NAME = "file-hgav"; 039 040 /** 041 * @since 1.9.25 042 */ 043 public static final String GAECV_NAME = "gaecv"; 044 045 /** 046 * @since 1.9.25 047 */ 048 public static final String FILE_GAECV_NAME = "file-gaecv"; 049 050 /** 051 * @since 1.9.25 052 */ 053 public static final String FILE_HGAECV_NAME = "file-hgaecv"; 054 055 /** 056 * @since 1.9.6 057 */ 058 public static final String FILE_STATIC_NAME = "file-static"; 059 060 public static final String DISCRIMINATING_NAME = "discriminating"; 061 062 public static NameMapper staticNameMapper() { 063 return new StaticNameMapper(); 064 } 065 066 public static NameMapper gavNameMapper() { 067 return gavNameMapper(false); 068 } 069 070 /** 071 * @since 1.9.25 072 */ 073 public static NameMapper gavNameMapper(boolean fileSystemFriendly) { 074 if (fileSystemFriendly) { 075 return new GAVNameMapper(true, "artifact~", ".lock", "metadata~", ".lock", "~"); 076 } else { 077 return new GAVNameMapper(false, "artifact:", "", "metadata:", "", ":"); 078 } 079 } 080 081 /** 082 * @since 1.9.25 083 */ 084 public static NameMapper gaecvNameMapper() { 085 return gaecvNameMapper(false); 086 } 087 088 /** 089 * @since 1.9.25 090 */ 091 public static NameMapper gaecvNameMapper(boolean fileSystemFriendly) { 092 if (fileSystemFriendly) { 093 return new GAECVNameMapper(true, "artifact~", ".lock", "metadata~", ".lock", "~"); 094 } else { 095 return new GAECVNameMapper(false, "artifact:", "", "metadata:", "", ":"); 096 } 097 } 098 099 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}