1 package org.apache.maven.surefire.group.match;
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
23 /**
24 * Inverse group matcher
25 *
26 */
27 public class InverseGroupMatcher
28 implements GroupMatcher
29 {
30
31 private final GroupMatcher matcher;
32
33 public InverseGroupMatcher( GroupMatcher matcher )
34 {
35 this.matcher = matcher;
36 }
37
38 public boolean enabled( Class<?>... cats )
39 {
40 return cats == null || !matcher.enabled( cats );
41 }
42
43 public boolean enabled( String... cats )
44 {
45 return cats == null || !matcher.enabled( cats );
46 }
47
48 @Override
49 public String toString()
50 {
51 return "NOT " + matcher;
52 }
53
54 @Override
55 public int hashCode()
56 {
57 final int prime = 31;
58 int result = 1;
59 result = prime * result + ( ( matcher == null ) ? 0 : matcher.hashCode() );
60 return result;
61 }
62
63 @Override
64 public boolean equals( Object obj )
65 {
66 if ( this == obj )
67 {
68 return true;
69 }
70 if ( obj == null )
71 {
72 return false;
73 }
74 if ( getClass() != obj.getClass() )
75 {
76 return false;
77 }
78 InverseGroupMatcher other = (InverseGroupMatcher) obj;
79 if ( matcher == null )
80 {
81 if ( other.matcher != null )
82 {
83 return false;
84 }
85 }
86 else if ( !matcher.equals( other.matcher ) )
87 {
88 return false;
89 }
90 return true;
91 }
92
93 public void loadGroupClasses( ClassLoader cloader )
94 {
95 matcher.loadGroupClasses( cloader );
96 }
97
98 }