*
* @param adaptedType The type.
* @return The adapting type, or null if not adaptable.
*/
public TypeMirror getAdaptingType(TypeMirror adaptedType) {
DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(adaptedType);
TypeMirror componentType = null;
if (decorated.isCollection()) {
Iterator<TypeMirror> itemTypes = ((DeclaredType) decorated).getActualTypeArguments().iterator();
if (!itemTypes.hasNext()) {
AnnotationProcessorEnvironment env = Context.getCurrentEnvironment();
Types typeUtils = env.getTypeUtils();
componentType = TypeMirrorDecorator.decorate(typeUtils.getDeclaredType(env.getTypeDeclaration(java.lang.Object.class.getName())));
}
else {
componentType = itemTypes.next();
}
}
else if (decorated.isArray()) {
componentType = ((ArrayType) decorated).getComponentType();
}
if (componentType instanceof ReferenceType && canAdapt((ReferenceType) componentType)) {
//if we can adapt the component type, then the adapting type is the collection of the declared adapting type.