use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class RestHolder method setExtends.
@Override
protected void setExtends() {
String annotatedComponentQualifiedName = annotatedElement.getQualifiedName().toString();
AbstractJClass annotatedComponent = getCodeModel().directClass(annotatedComponentQualifiedName);
generatedClass._implements(narrow(annotatedComponent));
}
use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class RoboGuiceHandler method beforeCreateMethod.
private void beforeCreateMethod(EActivityHolder holder, JFieldVar scope, JFieldVar scopedObjects, JFieldVar eventManager) {
JBlock body = holder.getInitBody();
AbstractJClass keyWildCard = getJClass(RoboGuiceClasses.KEY).narrow(getCodeModel().wildcard());
AbstractJClass scopedHashMap = getClasses().HASH_MAP.narrow(keyWildCard, getClasses().OBJECT);
body.assign(scopedObjects, JExpr._new(scopedHashMap));
JVar injector = body.decl(getJClass(RoboGuiceClasses.ROBO_INJECTOR), "injector_", getJClass(RoboGuiceClasses.ROBO_GUICE).staticInvoke("getInjector").arg(_this()));
body.assign(scope, invoke(injector, "getInstance").arg(getJClass(RoboGuiceClasses.CONTEXT_SCOPE).dotclass()));
body.assign(eventManager, invoke(injector, "getInstance").arg(getJClass(RoboGuiceClasses.EVENT_MANAGER).dotclass()));
body.add(injector.invoke("injectMembersWithoutViews").arg(_this()));
fireEvent(eventManager, body, getJClass(RoboGuiceClasses.ON_CREATE_EVENT), holder.getInitSavedInstanceParam());
}
use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class RestMethodHandler method addMethodParams.
protected SortedMap<String, JVar> addMethodParams(ExecutableElement executableElement, RestHolder restHolder, JMethod method) {
List<? extends VariableElement> params = executableElement.getParameters();
SortedMap<String, JVar> methodParams = new TreeMap<>();
for (VariableElement parameter : params) {
String paramName = parameter.getSimpleName().toString();
String paramType = parameter.asType().toString();
JVar param;
if (parameter.asType().getKind().isPrimitive()) {
param = method.param(getCodeModel().parseType(paramType), paramName);
} else {
AbstractJClass parameterClass = codeModelHelper.typeMirrorToJClass(parameter.asType());
param = method.param(parameterClass, paramName);
}
methodParams.put(paramName, param);
}
return methodParams;
}
use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class RestServiceHandler method assignValue.
@Override
public void assignValue(JBlock targetBlock, IJAssignmentTarget fieldRef, EComponentHolder holder, Element element, Element param) {
TypeMirror fieldTypeMirror = param.asType();
TypeMirror erasedFieldTypeMirror = getProcessingEnvironment().getTypeUtils().erasure(fieldTypeMirror);
String interfaceName = erasedFieldTypeMirror.toString();
String generatedClassName = interfaceName + classSuffix();
AbstractJClass clazz = codeModelHelper.narrowGeneratedClass(getJClass(generatedClassName), fieldTypeMirror);
targetBlock.add(fieldRef.assign(JExpr._new(clazz).arg(holder.getContextRef())));
}
use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class RestAnnotationHelper method retrieveResponseClass.
public AbstractJClass retrieveResponseClass(TypeMirror returnType, RestHolder holder) {
String returnTypeString = returnType.toString();
AbstractJClass responseClass;
if (returnTypeString.startsWith(RESPONSE_ENTITY)) {
DeclaredType declaredReturnType = (DeclaredType) returnType;
if (declaredReturnType.getTypeArguments().size() > 0) {
responseClass = resolveResponseClass(declaredReturnType.getTypeArguments().get(0), holder, false);
} else {
responseClass = getEnvironment().getJClass(RESPONSE_ENTITY);
}
} else {
responseClass = resolveResponseClass(returnType, holder, true);
}
return responseClass;
}
Aggregations