feroult / yawp

Kotlin/Java API framework for Google Appengine
http://yawp.io
MIT License
131 stars 19 forks source link

Allow Parameterized Types in Feature Hierarchy #96

Open feroult opened 8 years ago

feroult commented 8 years ago

Right now, we can't create a generic hook for a generic base class like this:

public abstract class BaseAggregator<T extends SomeClass> {
}
public class BaseHook<T extends SomeClass> extends Hook<BaseAggregator<T> {
}

To support this scenario, it is necessary to change the following ReflectionUtils method:

public static Class<?> getFeatureTypeArgumentAt(Class<?> clazz, int index) {
    Type superClassGenericType = getGenericTypeArgumentAt(clazz.getGenericSuperclass(), index);

    if (superClassGenericType instanceof TypeVariable) {
        return (Class<?>) getGenericTypeBound(clazz, ((TypeVariable) superClassGenericType).getName());
    }

    return (Class<?>) superClassGenericType;
}
luanpotter commented 7 years ago

Probably could replace that method with something like Java Classmate. Shouldn't be hard.