@@ -42,13 +42,8 @@ public abstract class TypeUtils {
42
42
* @return true if rhs is assignable to lhs
43
43
*/
44
44
public static boolean isAssignable (Type lhsType , Type rhsType ) {
45
- if (rhsType == null ) {
46
- return true ;
47
- }
48
-
49
- if (lhsType == null ) {
50
- return false ;
51
- }
45
+ Assert .notNull (lhsType , "Left-hand side type must not be null" );
46
+ Assert .notNull (rhsType , "Right-hand side type must not be null" );
52
47
53
48
// all types are assignable to themselves and to class Object
54
49
if (lhsType .equals (rhsType ) || lhsType .equals (Object .class )) {
@@ -175,46 +170,58 @@ private static boolean isAssignable(WildcardType lhsType, Type rhsType) {
175
170
176
171
for (Type lBound : lUpperBounds ) {
177
172
for (Type rBound : rUpperBounds ) {
178
- if (!isAssignable (lBound , rBound )) {
173
+ if (!isAssignableBound (lBound , rBound )) {
179
174
return false ;
180
175
}
181
176
}
182
177
183
178
for (Type rBound : rLowerBounds ) {
184
- if (!isAssignable (lBound , rBound )) {
179
+ if (!isAssignableBound (lBound , rBound )) {
185
180
return false ;
186
181
}
187
182
}
188
183
}
189
184
190
185
for (Type lBound : lLowerBounds ) {
191
186
for (Type rBound : rUpperBounds ) {
192
- if (!isAssignable (rBound , lBound )) {
187
+ if (!isAssignableBound (rBound , lBound )) {
193
188
return false ;
194
189
}
195
190
}
196
191
197
192
for (Type rBound : rLowerBounds ) {
198
- if (!isAssignable (rBound , lBound )) {
193
+ if (!isAssignableBound (rBound , lBound )) {
199
194
return false ;
200
195
}
201
196
}
202
197
}
203
198
}
204
199
else {
205
200
for (Type lBound : lUpperBounds ) {
206
- if (!isAssignable (lBound , rhsType )) {
201
+ if (!isAssignableBound (lBound , rhsType )) {
207
202
return false ;
208
203
}
209
204
}
210
205
211
206
for (Type lBound : lLowerBounds ) {
212
- if (!isAssignable (rhsType , lBound )) {
207
+ if (!isAssignableBound (rhsType , lBound )) {
213
208
return false ;
214
209
}
215
210
}
216
211
}
217
212
218
213
return true ;
219
214
}
215
+
216
+ public static boolean isAssignableBound (Type lhsType , Type rhsType ) {
217
+ if (rhsType == null ) {
218
+ return true ;
219
+ }
220
+
221
+ if (lhsType == null ) {
222
+ return false ;
223
+ }
224
+ return isAssignable (lhsType , rhsType );
225
+ }
226
+
220
227
}
0 commit comments