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.apache.maven.shared.artifact.filter.resolve; 20 21 import java.util.Collection; 22 import java.util.Collections; 23 24 /** 25 * A simple filter to exclude artifacts from a list of patterns. The artifact pattern syntax is of the form: 26 * 27 * <pre> 28 * [groupId]:[artifactId]:[extension]:[version] 29 * </pre> 30 * <p> 31 * Where each pattern segment is optional and supports full and partial <code>*</code> wildcards. An empty pattern 32 * segment is treated as an implicit wildcard. Version can be a range in case a {@code VersionScheme} is specified. 33 * </p> 34 * <p> 35 * For example, <code>org.apache.*</code> would match all artifacts whose group id started with 36 * <code>org.apache.</code> , and <code>:::*-SNAPSHOT</code> would match all snapshot artifacts. 37 * </p> 38 * 39 * @author Robert Scholte 40 * @since 3.0 41 * @see org.eclipse.aether.util.filter.PatternExclusionsDependencyFilter 42 * @see org.eclipse.aether.version.VersionScheme 43 */ 44 public class PatternExclusionsFilter implements TransformableFilter { 45 46 private final Collection<String> excludes; 47 48 /** 49 * The default constructor specifying a collection of pattern based keys which must be excluded. 50 * 51 * @param excludes the excludes, must not be {@code null} 52 */ 53 public PatternExclusionsFilter(Collection<String> excludes) { 54 this.excludes = Collections.unmodifiableCollection(excludes); 55 } 56 57 /** 58 * Get the excludes 59 * 60 * @return the excluded keys, never {@code null} 61 */ 62 public final Collection<String> getExcludes() { 63 return excludes; 64 } 65 66 /** 67 * {@inheritDoc} 68 * 69 * Transform this filter to a tool specific implementation 70 */ 71 @Override 72 public <T> T transform(FilterTransformer<T> transformer) { 73 return transformer.transform(this); 74 } 75 }