Skip to content

Package: MethodInfo

MethodInfo

nameinstructionbranchcomplexitylinemethod
MethodInfo(String, Class, Class[])
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
equals(Object)
M: 61 C: 0
0%
M: 20 C: 0
0%
M: 11 C: 0
0%
M: 20 C: 0
0%
M: 1 C: 0
0%
getName()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getParamTypes()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getReturnType()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
hashCode()
M: 40 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 1997, 2021 Oracle and/or its affiliates and others.
3: * All rights reserved.
4: * Copyright 2004 The Apache Software Foundation
5: *
6: * Licensed under the Apache License, Version 2.0 (the "License");
7: * you may not use this file except in compliance with the License.
8: * 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, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: package jakarta.el;
20:
21: import java.util.Arrays;
22:
23: /**
24: * Holds information about a method that a {@link MethodExpression} evaluated to.
25: *
26: * Two MethodInfo instances are considered to be equal if they reference methods
27: * with the same name, return types and parameter types.
28: *
29: * @since Jakarta Server Pages 2.1
30: */
31: public class MethodInfo {
32:
33: private String name;
34: private Class<?> returnType;
35: private Class<?>[] paramTypes;
36:
37: /**
38: * Creates a new instance of <code>MethodInfo</code> with the given information.
39: *
40: * @param name The name of the method
41: * @param returnType The return type of the method
42: * @param paramTypes The types of each of the method's parameters
43: */
44: public MethodInfo(String name, Class<?> returnType, Class<?>[] paramTypes) {
45: this.name = name;
46: this.returnType = returnType;
47: this.paramTypes = paramTypes;
48: }
49:
50: /**
51: * Returns the name of the method
52: *
53: * @return the name of the method
54: */
55: public String getName() {
56: return name;
57: }
58:
59: /**
60: * Returns the return type of the method
61: *
62: * @return the return type of the method
63: */
64: public Class<?> getReturnType() {
65: return returnType;
66: }
67:
68: /**
69: * Returns the parameter types of the method
70: *
71: * @return the parameter types of the method
72: */
73: public Class<?>[] getParamTypes() {
74: return paramTypes;
75: }
76:
77: @Override
78: public int hashCode() {
79: final int prime = 31;
80: int result = 1;
81:• result = prime * result + ((name == null) ? 0 : name.hashCode());
82: result = prime * result + Arrays.hashCode(paramTypes);
83:• result = prime * result + ((returnType == null) ? 0 : returnType.hashCode());
84: return result;
85: }
86:
87: @Override
88: public boolean equals(Object obj) {
89:• if (this == obj) {
90: return true;
91: }
92:• if (obj == null) {
93: return false;
94: }
95:• if (getClass() != obj.getClass()) {
96: return false;
97: }
98: MethodInfo other = (MethodInfo) obj;
99:• if (name == null) {
100:• if (other.name != null) {
101: return false;
102: }
103:• } else if (!name.equals(other.name)) {
104: return false;
105: }
106:• if (!Arrays.equals(paramTypes, other.paramTypes)) {
107: return false;
108: }
109:• if (returnType == null) {
110:• if (other.returnType != null) {
111: return false;
112: }
113:• } else if (!returnType.equals(other.returnType)) {
114: return false;
115: }
116: return true;
117: }
118: }