OptionalMethod.java
3.67 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package com.squareup.okhttp.internal;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
class OptionalMethod<T>
{
private final String methodName;
private final Class[] methodParams;
private final Class<?> returnType;
public OptionalMethod(Class<?> paramClass, String paramString, Class... paramVarArgs)
{
this.returnType = paramClass;
this.methodName = paramString;
this.methodParams = paramVarArgs;
}
private Method getMethod(Class<?> paramClass)
{
if (this.methodName != null)
{
paramClass = getPublicMethod(paramClass, this.methodName, this.methodParams);
if ((paramClass == null) || (this.returnType == null) || (this.returnType.isAssignableFrom(paramClass.getReturnType()))) {}
}
else
{
return null;
}
return paramClass;
}
private static Method getPublicMethod(Class<?> paramClass, String paramString, Class[] paramArrayOfClass)
{
try
{
paramClass = paramClass.getMethod(paramString, paramArrayOfClass);
int i;
return paramClass;
}
catch (NoSuchMethodException paramClass)
{
try
{
i = paramClass.getModifiers();
if ((i & 0x1) != 0) {
return paramClass;
}
return null;
}
catch (NoSuchMethodException paramString)
{
return paramClass;
}
paramClass = paramClass;
return null;
}
}
public Object invoke(T paramT, Object... paramVarArgs)
throws InvocationTargetException
{
Method localMethod = getMethod(paramT.getClass());
if (localMethod == null) {
throw new AssertionError("Method " + this.methodName + " not supported for object " + paramT);
}
try
{
paramT = localMethod.invoke(paramT, paramVarArgs);
return paramT;
}
catch (IllegalAccessException paramT)
{
paramVarArgs = new AssertionError("Unexpectedly could not call: " + localMethod);
paramVarArgs.initCause(paramT);
throw paramVarArgs;
}
}
public Object invokeOptional(T paramT, Object... paramVarArgs)
throws InvocationTargetException
{
Method localMethod = getMethod(paramT.getClass());
if (localMethod == null) {
return null;
}
try
{
paramT = localMethod.invoke(paramT, paramVarArgs);
return paramT;
}
catch (IllegalAccessException paramT) {}
return null;
}
public Object invokeOptionalWithoutCheckedException(T paramT, Object... paramVarArgs)
{
try
{
paramT = invokeOptional(paramT, paramVarArgs);
return paramT;
}
catch (InvocationTargetException paramT)
{
paramT = paramT.getTargetException();
if ((paramT instanceof RuntimeException)) {
throw ((RuntimeException)paramT);
}
paramVarArgs = new AssertionError("Unexpected exception");
paramVarArgs.initCause(paramT);
throw paramVarArgs;
}
}
public Object invokeWithoutCheckedException(T paramT, Object... paramVarArgs)
{
try
{
paramT = invoke(paramT, paramVarArgs);
return paramT;
}
catch (InvocationTargetException paramT)
{
paramT = paramT.getTargetException();
if ((paramT instanceof RuntimeException)) {
throw ((RuntimeException)paramT);
}
paramVarArgs = new AssertionError("Unexpected exception");
paramVarArgs.initCause(paramT);
throw paramVarArgs;
}
}
public boolean isSupported(T paramT)
{
return getMethod(paramT.getClass()) != null;
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/okhttp/internal/OptionalMethod.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/