1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.maven.surefire.api.util.internal;
20
21 import java.util.Objects;
22
23 import static org.apache.maven.surefire.shared.utils.StringUtils.isBlank;
24
25 /**
26 * Data transfer object of class and method literals.
27 */
28 public final class ClassMethod {
29 private final String clazz;
30
31 private final String method;
32
33 public ClassMethod(String clazz, String method) {
34 this.clazz = clazz;
35 this.method = method;
36 }
37
38 public boolean isValidTest() {
39 return !isBlank(clazz) && !isBlank(method);
40 }
41
42 public String getClazz() {
43 return clazz;
44 }
45
46 public String getMethod() {
47 return method;
48 }
49
50 @Override
51 public boolean equals(Object o) {
52 if (this == o) {
53 return true;
54 }
55 if (o == null || getClass() != o.getClass()) {
56 return false;
57 }
58 ClassMethod that = (ClassMethod) o;
59 return Objects.equals(clazz, that.clazz) && Objects.equals(method, that.method);
60 }
61
62 @Override
63 public int hashCode() {
64 return Objects.hash(clazz, method);
65 }
66 }