001package org.eclipse.aether.util.filter; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.util.Collection; 023 024import org.eclipse.aether.artifact.Artifact; 025import org.eclipse.aether.version.VersionScheme; 026 027/** 028 * A simple filter to exclude artifacts from a list of patterns. The artifact pattern syntax is of the form: 029 * 030 * <pre> 031 * [groupId]:[artifactId]:[extension]:[version] 032 * </pre> 033 * <p> 034 * Where each pattern segment is optional and supports full and partial <code>*</code> wildcards. An empty pattern 035 * segment is treated as an implicit wildcard. Version can be a range in case a {@link VersionScheme} is specified. 036 * </p> 037 * <p> 038 * For example, <code>org.eclipse.*</code> would match all artifacts whose group id started with 039 * <code>org.eclipse.</code> , and <code>:::*-SNAPSHOT</code> would match all snapshot artifacts. 040 * </p> 041 */ 042public final class PatternExclusionsDependencyFilter 043 extends AbstractPatternDependencyFilter 044{ 045 046 /** 047 * Creates a new filter using the specified patterns. 048 * 049 * @param patterns The exclude patterns, may be {@code null} or empty to exclude no artifacts. 050 */ 051 public PatternExclusionsDependencyFilter( final String... patterns ) 052 { 053 super( patterns ); 054 } 055 056 /** 057 * Creates a new filter using the specified patterns. 058 * 059 * @param versionScheme To be used for parsing versions/version ranges. If {@code null} and pattern specifies a 060 * range no artifact will be excluded. 061 * @param patterns The exclude patterns, may be {@code null} or empty to exclude no artifacts. 062 */ 063 public PatternExclusionsDependencyFilter( final VersionScheme versionScheme, final String... patterns ) 064 { 065 super( versionScheme, patterns ); 066 } 067 068 /** 069 * Creates a new filter using the specified patterns. 070 * 071 * @param patterns The include patterns, may be {@code null} or empty to include no artifacts. 072 */ 073 public PatternExclusionsDependencyFilter( final Collection<String> patterns ) 074 { 075 super( patterns ); 076 } 077 078 /** 079 * Creates a new filter using the specified patterns and {@link VersionScheme} . 080 * 081 * @param versionScheme To be used for parsing versions/version ranges. If {@code null} and pattern specifies a 082 * range no artifact will be excluded. 083 * @param patterns The exclude patterns, may be {@code null} or empty to exclude no artifacts. 084 */ 085 public PatternExclusionsDependencyFilter( final VersionScheme versionScheme, final Collection<String> patterns ) 086 { 087 super( versionScheme, patterns ); 088 } 089 090 @Override 091 protected boolean accept( Artifact artifact ) 092 { 093 return !super.accept( artifact ); 094 } 095 096}