View Javadoc

1   package org.apache.maven.surefire.group.match;
2   /*
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  
21  
22  public class InverseGroupMatcher
23      implements GroupMatcher
24  {
25  
26      private final GroupMatcher matcher;
27  
28      public InverseGroupMatcher( GroupMatcher matcher )
29      {
30          this.matcher = matcher;
31      }
32  
33      public boolean enabled( Class<?>... cats )
34      {
35          return cats == null || !matcher.enabled( cats );
36      }
37  
38      public boolean enabled( String... cats )
39      {
40          return cats == null || !matcher.enabled( cats );
41      }
42  
43      @Override
44      public String toString()
45      {
46          return "NOT " + matcher;
47      }
48  
49      @Override
50      public int hashCode()
51      {
52          final int prime = 31;
53          int result = 1;
54          result = prime * result + ( ( matcher == null ) ? 0 : matcher.hashCode() );
55          return result;
56      }
57  
58      @Override
59      public boolean equals( Object obj )
60      {
61          if ( this == obj )
62          {
63              return true;
64          }
65          if ( obj == null )
66          {
67              return false;
68          }
69          if ( getClass() != obj.getClass() )
70          {
71              return false;
72          }
73          InverseGroupMatcher other = (InverseGroupMatcher) obj;
74          if ( matcher == null )
75          {
76              if ( other.matcher != null )
77              {
78                  return false;
79              }
80          }
81          else if ( !matcher.equals( other.matcher ) )
82          {
83              return false;
84          }
85          return true;
86      }
87  
88      public void loadGroupClasses( ClassLoader cloader )
89      {
90          matcher.loadGroupClasses( cloader );
91      }
92  
93  }