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.util.filter; 20 21 import java.util.Collection; 22 23 import org.eclipse.aether.artifact.Artifact; 24 import org.eclipse.aether.version.VersionScheme; 25 26 /** 27 * A simple filter to exclude artifacts from a list of patterns. The artifact pattern syntax is of the form: 28 * 29 * <pre> 30 * [groupId]:[artifactId]:[extension]:[version] 31 * </pre> 32 * <p> 33 * Where each pattern segment is optional and supports full and partial <code>*</code> wildcards. An empty pattern 34 * segment is treated as an implicit wildcard. Version can be a range in case a {@link VersionScheme} is specified. 35 * </p> 36 * <p> 37 * For example, <code>org.eclipse.*</code> would match all artifacts whose group id started with 38 * <code>org.eclipse.</code> , and <code>:::*-SNAPSHOT</code> would match all snapshot artifacts. 39 * </p> 40 */ 41 public final class PatternExclusionsDependencyFilter extends AbstractPatternDependencyFilter { 42 43 /** 44 * Creates a new filter using the specified patterns. 45 * 46 * @param patterns The exclude patterns, may be {@code null} or empty to exclude no artifacts. 47 */ 48 public PatternExclusionsDependencyFilter(final String... patterns) { 49 super(patterns); 50 } 51 52 /** 53 * Creates a new filter using the specified patterns. 54 * 55 * @param versionScheme To be used for parsing versions/version ranges. If {@code null} and pattern specifies a 56 * range no artifact will be excluded. 57 * @param patterns The exclude patterns, may be {@code null} or empty to exclude no artifacts. 58 */ 59 public PatternExclusionsDependencyFilter(final VersionScheme versionScheme, final String... patterns) { 60 super(versionScheme, patterns); 61 } 62 63 /** 64 * Creates a new filter using the specified patterns. 65 * 66 * @param patterns The include patterns, may be {@code null} or empty to include no artifacts. 67 */ 68 public PatternExclusionsDependencyFilter(final Collection<String> patterns) { 69 super(patterns); 70 } 71 72 /** 73 * Creates a new filter using the specified patterns and {@link VersionScheme} . 74 * 75 * @param versionScheme To be used for parsing versions/version ranges. If {@code null} and pattern specifies a 76 * range no artifact will be excluded. 77 * @param patterns The exclude patterns, may be {@code null} or empty to exclude no artifacts. 78 */ 79 public PatternExclusionsDependencyFilter(final VersionScheme versionScheme, final Collection<String> patterns) { 80 super(versionScheme, patterns); 81 } 82 83 @Override 84 protected boolean accept(Artifact artifact) { 85 return !super.accept(artifact); 86 } 87 }