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
71 if ( obj == null || getClass() != obj.getClass() )
72 {
73 return false;
74 }
75 InverseGroupMatcher other = (InverseGroupMatcher) obj;
76 if ( matcher == null )
77 {
78 if ( other.matcher != null )
79 {
80 return false;
81 }
82 }
83 else if ( !matcher.equals( other.matcher ) )
84 {
85 return false;
86 }
87 return true;
88 }
89
90 public void loadGroupClasses( ClassLoader cloader )
91 {
92 matcher.loadGroupClasses( cloader );
93 }
94
95 }