if (!(boundTypeMirror instanceof ReferenceType)) {
throw new ValidationException(adapterDeclaration.getPosition(), adapterDeclaration.getQualifiedName() + ": illegal XML adapter: not adapting a reference type (" + boundTypeMirror + ").");
}
else while (boundTypeMirror instanceof TypeVariable) {
//unwrap the type variable to find the bounds.
TypeParameterDeclaration declaration = ((TypeVariable) boundTypeMirror).getDeclaration();
if (declaration == null) {
throw new IllegalStateException(adapterDeclaration.getQualifiedName() + ": unable to find type parameter declaration for type variable " + boundTypeMirror + ".");
}
else if (declaration.getBounds() != null && !declaration.getBounds().isEmpty()) {
boundTypeMirror = declaration.getBounds().iterator().next();
}
else {
AnnotationProcessorEnvironment env = Context.getCurrentEnvironment();
boundTypeMirror = env.getTypeUtils().getDeclaredType(env.getTypeDeclaration(Object.class.getName()));
}