TypeDeclaration declaration = declaredType.getDeclaration();
if (declaration == null) {
return null;
}
else if ("java.util.Map".equals(declaration.getQualifiedName())) {
TypeMirror keyType = null;
TypeMirror valueType = null;
Collection<TypeMirror> typeArgs = declaredType.getActualTypeArguments();
if ((typeArgs != null) && (typeArgs.size() == 2)) {
Iterator<TypeMirror> argIt = typeArgs.iterator();
keyType = argIt.next();
valueType = argIt.next();
}
if ((keyType == null) || (valueType == null)) {
AnnotationProcessorEnvironment env = Context.getCurrentEnvironment();
TypeMirror objectType = env.getTypeUtils().getDeclaredType(env.getTypeDeclaration(Object.class.getName()));
keyType = objectType;
valueType = objectType;
}
return new MapType((InterfaceType) declaredType, keyType, valueType);