blob: 6c44da01d344cb3df91b275647d666bd356dd9ab (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/*******************************************************************************
* Copyright (c) 2016 Dennis Wagelaar.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dennis Wagelaar - initial API and
* implementation and/or initial documentation
*******************************************************************************/
package org.eclipse.m2m.atl.emftvm.util;
import java.lang.reflect.Method;
import java.util.Arrays;
/**
* {@link Method} signature for EMFTVM method caching.
*
* @author <a href="mailto:dwagelaar@gmail.com">Dennis Wagelaar</a>
*/
public final class MethodSignature {
private final String name;
private final Class<?>[] argumentTypes;
private final boolean isStatic;
/**
* Creates a new {@link MethodSignature}.
*
* @param name
* the method name
* @param argumentTypes
* the method argument types
* @param isStatic
* whether the method is static
*/
public MethodSignature(String name, Class<?>[] argumentTypes, boolean isStatic) {
super();
this.name = name;
this.argumentTypes = argumentTypes;
this.isStatic = isStatic;
}
/**
* Returns the method name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Returns the method argument types.
*
* @return the argumentTypes
*/
public Class<?>[] getArgumentTypes() {
return argumentTypes;
}
/**
* Returns whether the method is static.
*
* @return the isStatic
*/
public boolean isStatic() {
return isStatic;
}
/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode(argumentTypes);
result = prime * result + (isStatic ? 1231 : 1237);
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
/**
* {@inheritDoc}
*/
@Override
public boolean equals(final Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
MethodSignature other = (MethodSignature) obj;
if (!Arrays.equals(argumentTypes, other.argumentTypes))
return false;
if (isStatic != other.isStatic)
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "MethodSignature [name=" + name + ", argumentTypes=" + Arrays.toString(argumentTypes) + ", isStatic="
+ isStatic + "]";
}
}
|