This commit is contained in:
@@ -95,7 +95,7 @@ public final class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T
|
||||
if (factory.isConvertDisabled(field)) continue;
|
||||
ref = factory.findRef(field);
|
||||
if (ref != null && ref.ignore()) continue;
|
||||
Type t = TypeToken.createClassType(TypeToken.getGenericType(field.getGenericType(), clazz), this.type);
|
||||
Type t = TypeToken.createClassType(TypeToken.getGenericType(field.getGenericType(), this.type), this.type);
|
||||
DeMember member = new DeMember(ObjectEncoder.createAttribute(factory, clazz, field, null, null), factory.loadDecoder(t));
|
||||
if (ref != null) member.index = ref.getIndex();
|
||||
list.add(member);
|
||||
@@ -120,7 +120,7 @@ public final class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T
|
||||
}
|
||||
ref = factory.findRef(method);
|
||||
if (ref != null && ref.ignore()) continue;
|
||||
Type t = TypeToken.createClassType(TypeToken.getGenericType(method.getGenericParameterTypes()[0], clazz), this.type);
|
||||
Type t = TypeToken.createClassType(TypeToken.getGenericType(method.getGenericParameterTypes()[0], this.type), this.type);
|
||||
DeMember member = new DeMember(ObjectEncoder.createAttribute(factory, clazz, null, null, method), factory.loadDecoder(t));
|
||||
if (ref != null) member.index = ref.getIndex();
|
||||
list.add(member);
|
||||
@@ -150,7 +150,7 @@ public final class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T
|
||||
} catch (NoSuchMethodException ex) {
|
||||
getter = clazz.getMethod("is" + mn);
|
||||
}
|
||||
Type t = TypeToken.createClassType(TypeToken.getGenericType(getter.getGenericParameterTypes()[0], clazz), this.type);
|
||||
Type t = TypeToken.createClassType(TypeToken.getGenericType(getter.getGenericParameterTypes()[0], this.type), this.type);
|
||||
list.add(new DeMember(ObjectEncoder.createAttribute(factory, clazz, null, getter, null), factory.loadDecoder(t)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public final class ObjectEncoder<W extends Writer, T> implements Encodeable<W, T
|
||||
if (factory.isConvertDisabled(field)) continue;
|
||||
ref = factory.findRef(field);
|
||||
if (ref != null && ref.ignore()) continue;
|
||||
Type t = TypeToken.createClassType(TypeToken.getGenericType(field.getGenericType(), clazz), this.type);
|
||||
Type t = TypeToken.createClassType(TypeToken.getGenericType(field.getGenericType(), this.type), this.type);
|
||||
EnMember member = new EnMember(createAttribute(factory, clazz, field, null, null), factory.loadEncoder(t));
|
||||
if (ref != null) member.index = ref.getIndex();
|
||||
list.add(member);
|
||||
@@ -102,7 +102,7 @@ public final class ObjectEncoder<W extends Writer, T> implements Encodeable<W, T
|
||||
}
|
||||
ref = factory.findRef(method);
|
||||
if (ref != null && ref.ignore()) continue;
|
||||
Type t = TypeToken.createClassType(TypeToken.getGenericType(method.getGenericReturnType(), clazz), this.type);
|
||||
Type t = TypeToken.createClassType(TypeToken.getGenericType(method.getGenericReturnType(), this.type), this.type);
|
||||
EnMember member = new EnMember(createAttribute(factory, clazz, null, method, null), factory.loadEncoder(t));
|
||||
if (ref != null) member.index = ref.getIndex();
|
||||
list.add(member);
|
||||
|
||||
@@ -98,23 +98,29 @@ public abstract class TypeToken<T> {
|
||||
public static Type getGenericType(final Type type, final Type declaringClass) {
|
||||
if (type == null || declaringClass == null) return type;
|
||||
if (type instanceof TypeVariable) {
|
||||
Type superType = null;
|
||||
Class declaringClass0 = null;
|
||||
if (declaringClass instanceof Class) {
|
||||
final Class declaringClass0 = (Class) declaringClass;
|
||||
Type superType = declaringClass0.getGenericSuperclass();
|
||||
declaringClass0 = (Class) declaringClass;
|
||||
superType = declaringClass0.getGenericSuperclass();
|
||||
while (superType instanceof Class && superType != Object.class) superType = ((Class) superType).getGenericSuperclass();
|
||||
if (superType instanceof ParameterizedType) {
|
||||
ParameterizedType superPT = (ParameterizedType) superType;
|
||||
Type[] atas = superPT.getActualTypeArguments();
|
||||
Class ss = declaringClass0;
|
||||
TypeVariable[] asts = ss.getTypeParameters();
|
||||
while (atas.length != asts.length && ss != Object.class) {
|
||||
ss = ss.getSuperclass();
|
||||
asts = ss.getTypeParameters();
|
||||
}
|
||||
if (atas.length == asts.length) {
|
||||
for (int i = 0; i < asts.length; i++) {
|
||||
if (asts[i] == type) return atas[i];
|
||||
}
|
||||
} else if (declaringClass instanceof ParameterizedType) {
|
||||
superType = declaringClass;
|
||||
Type rawType = ((ParameterizedType) declaringClass).getRawType();
|
||||
if (rawType instanceof Class) declaringClass0 = (Class) rawType;
|
||||
}
|
||||
if (declaringClass0 != null && superType instanceof ParameterizedType) {
|
||||
ParameterizedType superPT = (ParameterizedType) superType;
|
||||
Type[] atas = superPT.getActualTypeArguments();
|
||||
Class ss = declaringClass0;
|
||||
TypeVariable[] asts = ss.getTypeParameters();
|
||||
while (atas.length != asts.length && ss != Object.class) {
|
||||
ss = ss.getSuperclass();
|
||||
asts = ss.getTypeParameters();
|
||||
}
|
||||
if (atas.length == asts.length) {
|
||||
for (int i = 0; i < asts.length; i++) {
|
||||
if (asts[i] == type) return atas[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user