declaredEntityParameters.add(entityParameter);
customParameterName = parameterDeclaration.getSimpleName();
}
}
DecoratedTypeMirror returnTypeMirror;
TypeHint hintInfo = getAnnotation(TypeHint.class);
if (hintInfo != null) {
try {
Class hint = hintInfo.value();
AnnotationProcessorEnvironment env = net.sf.jelly.apt.Context.getCurrentEnvironment();
if (TypeHint.NO_CONTENT.class.equals(hint)) {
returnTypeMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(env.getTypeUtils().getVoidType());
}
else {
String hintName = hint.getName();
if (TypeHint.NONE.class.equals(hint)) {
hintName = hintInfo.qualifiedName();
}
if (!"##NONE".equals(hintName)) {
TypeDeclaration type = env.getTypeDeclaration(hintName);
returnTypeMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(env.getTypeUtils().getDeclaredType(type));
}
else {
returnTypeMirror = (DecoratedTypeMirror) getReturnType();
}
}
}
catch (MirroredTypeException e) {
returnTypeMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(e.getTypeMirror());
}
returnTypeMirror.setDocComment(((DecoratedTypeMirror) getReturnType()).getDocComment());
}
else {
returnTypeMirror = (DecoratedTypeMirror) getReturnType();
if (getJavaDoc().get("returnWrapped") != null) { //support jax-doclets. see http://jira.codehaus.org/browse/ENUNCIATE-690
String fqn = getJavaDoc().get("returnWrapped").get(0);
AnnotationProcessorEnvironment env = net.sf.jelly.apt.Context.getCurrentEnvironment();
TypeDeclaration type = env.getTypeDeclaration(fqn);
if (type != null) {
returnTypeMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(env.getTypeUtils().getDeclaredType(type));
}
}
// in the case where the return type is com.sun.jersey.api.JResponse,
// we can use the type argument to get the entity type
if (returnTypeMirror.isClass() && returnTypeMirror.isInstanceOf("com.sun.jersey.api.JResponse")) {
DecoratedClassType jresponse = (DecoratedClassType) returnTypeMirror;
if (!jresponse.getActualTypeArguments().isEmpty()) {
DecoratedTypeMirror responseType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(jresponse.getActualTypeArguments().iterator().next());
if (responseType.isDeclared()) {
responseType.setDocComment(returnTypeMirror.getDocComment());
returnTypeMirror = responseType;
}
}
}
}