|
29 | 29 | */
|
30 | 30 | package fr.zcraft.zlib.tools.reflection;
|
31 | 31 |
|
| 32 | +import org.apache.commons.lang.ArrayUtils; |
32 | 33 | import org.bukkit.Bukkit;
|
33 | 34 |
|
34 |
| -import java.lang.reflect.Constructor; |
35 |
| -import java.lang.reflect.Field; |
36 |
| -import java.lang.reflect.InvocationTargetException; |
37 |
| -import java.lang.reflect.Method; |
38 |
| -import java.lang.reflect.Type; |
| 35 | +import java.lang.reflect.*; |
39 | 36 | import java.util.ArrayList;
|
40 | 37 | import java.util.Arrays;
|
41 | 38 | import java.util.Collection;
|
@@ -188,7 +185,7 @@ static public Field getField(Class<?> klass, Class<?> type) throws NoSuchFieldEx
|
188 | 185 | {
|
189 | 186 | for (Field field : klass.getDeclaredFields())
|
190 | 187 | {
|
191 |
| - if (field.getType().equals(type)) |
| 188 | + if (typeIsAssignableFrom(field.getType(), type)) |
192 | 189 | {
|
193 | 190 | field.setAccessible(true);
|
194 | 191 | return field;
|
@@ -425,6 +422,9 @@ static private boolean nameMatches(String methodName, String pattern)
|
425 | 422 |
|
426 | 423 | static public boolean typeIsAssignableFrom(Type source, Type destination)
|
427 | 424 | {
|
| 425 | + if(source instanceof ParameterizedType) source = ((ParameterizedType) source).getRawType(); |
| 426 | + if(destination instanceof ParameterizedType) source = ((ParameterizedType) destination).getRawType(); |
| 427 | + |
428 | 428 | if(source instanceof Class && destination instanceof Class)
|
429 | 429 | {
|
430 | 430 | return ((Class<?>)destination).isAssignableFrom((Class) source);
|
|
0 commit comments