View Javadoc
1   package org.eclipse.aether.util.filter;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   * 
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   * 
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.Collection;
23  
24  import org.eclipse.aether.artifact.Artifact;
25  import org.eclipse.aether.version.VersionScheme;
26  
27  /**
28   * A simple filter to exclude artifacts from a list of patterns. The artifact pattern syntax is of the form:
29   * 
30   * <pre>
31   * [groupId]:[artifactId]:[extension]:[version]
32   * </pre>
33   * <p>
34   * Where each pattern segment is optional and supports full and partial <code>*</code> wildcards. An empty pattern
35   * segment is treated as an implicit wildcard. Version can be a range in case a {@link VersionScheme} is specified.
36   * </p>
37   * <p>
38   * For example, <code>org.eclipse.*</code> would match all artifacts whose group id started with
39   * <code>org.eclipse.</code> , and <code>:::*-SNAPSHOT</code> would match all snapshot artifacts.
40   * </p>
41   */
42  public final class PatternExclusionsDependencyFilter
43      extends AbstractPatternDependencyFilter
44  {
45  
46      /**
47       * Creates a new filter using the specified patterns.
48       * 
49       * @param patterns The exclude patterns, may be {@code null} or empty to exclude no artifacts.
50       */
51      public PatternExclusionsDependencyFilter( final String... patterns )
52      {
53          super( patterns );
54      }
55  
56      /**
57       * Creates a new filter using the specified patterns.
58       * 
59       * @param versionScheme To be used for parsing versions/version ranges. If {@code null} and pattern specifies a
60       *            range no artifact will be excluded.
61       * @param patterns The exclude patterns, may be {@code null} or empty to exclude no artifacts.
62       */
63      public PatternExclusionsDependencyFilter( final VersionScheme versionScheme, final String... patterns )
64      {
65          super( versionScheme, patterns );
66      }
67  
68      /**
69       * Creates a new filter using the specified patterns.
70       * 
71       * @param patterns The include patterns, may be {@code null} or empty to include no artifacts.
72       */
73      public PatternExclusionsDependencyFilter( final Collection<String> patterns )
74      {
75          super( patterns );
76      }
77  
78      /**
79       * Creates a new filter using the specified patterns and {@link VersionScheme} .
80       * 
81       * @param versionScheme To be used for parsing versions/version ranges. If {@code null} and pattern specifies a
82       *            range no artifact will be excluded.
83       * @param patterns The exclude patterns, may be {@code null} or empty to exclude no artifacts.
84       */
85      public PatternExclusionsDependencyFilter( final VersionScheme versionScheme, final Collection<String> patterns )
86      {
87          super( versionScheme, patterns );
88      }
89  
90      @Override
91      protected boolean accept( Artifact artifact )
92      {
93          return !super.accept( artifact );
94      }
95  
96  }