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