static JClassType getUserPrefsType(TreeLogger logger, TypeOracle typeOracle,
JClassType extendsGadget) throws UnableToCompleteException {
JGenericType gadgetType = typeOracle.findType(Gadget.class.getName()).isGenericType();
assert gadgetType != null;
JParameterizedType paramType = null;
while (true) {
paramType = extendsGadget.isParameterized();
if (paramType != null && gadgetType.equals(paramType.getBaseType())) {
break;
}
extendsGadget = extendsGadget.getSuperclass();
if (extendsGadget == null) {
logger.log(TreeLogger.ERROR, "Unable to find Gadget in type hierarchy",
null);
throw new UnableToCompleteException();
}
}
JClassType[] typeArgs = paramType.getTypeArgs();
assert typeArgs.length == 1;
JClassType toReturn = typeArgs[0].isClassOrInterface();
if (toReturn == null) {
logger.log(TreeLogger.ERROR,