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.util.filter; 020 021import java.util.Collection; 022 023import org.eclipse.aether.artifact.Artifact; 024import org.eclipse.aether.version.VersionScheme; 025 026/** 027 * A simple filter to exclude artifacts from a list of patterns. The artifact pattern syntax is of the form: 028 * 029 * <pre> 030 * [groupId]:[artifactId]:[extension]:[version] 031 * </pre> 032 * <p> 033 * Where each pattern segment is optional and supports full and partial <code>*</code> wildcards. An empty pattern 034 * segment is treated as an implicit wildcard. Version can be a range in case a {@link VersionScheme} is specified. 035 * </p> 036 * <p> 037 * For example, <code>org.eclipse.*</code> would match all artifacts whose group id started with 038 * <code>org.eclipse.</code> , and <code>:::*-SNAPSHOT</code> would match all snapshot artifacts. 039 * </p> 040 */ 041public final class PatternExclusionsDependencyFilter extends AbstractPatternDependencyFilter { 042 043 /** 044 * Creates a new filter using the specified patterns. 045 * 046 * @param patterns The exclude patterns, may be {@code null} or empty to exclude no artifacts. 047 */ 048 public PatternExclusionsDependencyFilter(final String... patterns) { 049 super(patterns); 050 } 051 052 /** 053 * Creates a new filter using the specified patterns. 054 * 055 * @param versionScheme To be used for parsing versions/version ranges. If {@code null} and pattern specifies a 056 * range no artifact will be excluded. 057 * @param patterns The exclude patterns, may be {@code null} or empty to exclude no artifacts. 058 */ 059 public PatternExclusionsDependencyFilter(final VersionScheme versionScheme, final String... patterns) { 060 super(versionScheme, patterns); 061 } 062 063 /** 064 * Creates a new filter using the specified patterns. 065 * 066 * @param patterns The include patterns, may be {@code null} or empty to include no artifacts. 067 */ 068 public PatternExclusionsDependencyFilter(final Collection<String> patterns) { 069 super(patterns); 070 } 071 072 /** 073 * Creates a new filter using the specified patterns and {@link VersionScheme} . 074 * 075 * @param versionScheme To be used for parsing versions/version ranges. If {@code null} and pattern specifies a 076 * range no artifact will be excluded. 077 * @param patterns The exclude patterns, may be {@code null} or empty to exclude no artifacts. 078 */ 079 public PatternExclusionsDependencyFilter(final VersionScheme versionScheme, final Collection<String> patterns) { 080 super(versionScheme, patterns); 081 } 082 083 @Override 084 protected boolean accept(Artifact artifact) { 085 return !super.accept(artifact); 086 } 087}