public JMethod implementMethod(GeneratedClassHolder holder, List<ExecutableElement> methods, String methodName, String returnType, String... parameterTypes) { return implementMethod(holder, methods, methodName, returnType, false, parameterTypes); }
private void implementGetRestTemplate(List<ExecutableElement> methods) { JMethod getRestTemplateMethod = codeModelHelper.implementMethod(this, methods, null, REST_TEMPLATE); if (getRestTemplateMethod != null) { getRestTemplateMethod.body()._return(getRestTemplateField()); } }
private void implementGetRootUrl(List<ExecutableElement> methods) { JMethod getRootUrlMethod = codeModelHelper.implementMethod(this, methods, "getRootUrl", STRING); if (getRootUrlMethod != null) { getRootUrlMethod.body()._return(getRootUrlField()); } }
private void implementGetHeader(List<ExecutableElement> methods) { JMethod getHeaderMethod = codeModelHelper.implementMethod(this, methods, "getHeader", STRING, STRING); if (getHeaderMethod != null) { JInvocation headerValue = JExpr.invoke(getAvailableHeadersField(), "get").arg(getHeaderMethod.params().get(0)); getHeaderMethod.body()._return(headerValue); } }
private void implementGetCookie(List<ExecutableElement> methods) { JMethod getCookieMethod = codeModelHelper.implementMethod(this, methods, "getCookie", STRING, STRING); if (getCookieMethod != null) { JInvocation cookieValue = JExpr.invoke(getAvailableCookiesField(), "get").arg(getCookieMethod.params().get(0)); getCookieMethod.body()._return(cookieValue); } }
private void implementSetCookie(List<ExecutableElement> methods) { JMethod setCookieMethod = codeModelHelper.implementMethod(this, methods, "setCookie", TypeKind.VOID.toString(), STRING, STRING); if (setCookieMethod != null) { setCookieMethod.body().invoke(getAvailableCookiesField(), "put").arg(setCookieMethod.params().get(0)).arg(setCookieMethod.params().get(1)); } }
private void implementSetAuthentication(List<ExecutableElement> methods) { JMethod setAuthMethod = codeModelHelper.implementMethod(this, methods, "setAuthentication", TypeKind.VOID.toString(), HTTP_AUTHENTICATION); if (setAuthMethod != null) { setAuthMethod.body().assign(_this().ref(getAuthenticationField()), setAuthMethod.params().get(0)); } }
private void implementSetHeader(List<ExecutableElement> methods) { JMethod setHeaderMethod = codeModelHelper.implementMethod(this, methods, "setHeader", TypeKind.VOID.toString(), STRING, STRING); if (setHeaderMethod != null) { setHeaderMethod.body().invoke(getAvailableHeadersField(), "put").arg(setHeaderMethod.params().get(0)).arg(setHeaderMethod.params().get(1)); } }
private void implementSetErrorHandler(List<ExecutableElement> methods) { JMethod setErrorHandlerMethod = codeModelHelper.implementMethod(this, methods, "setRestErrorHandler", TypeKind.VOID.toString(), RestErrorHandler.class.getName()); if (setErrorHandlerMethod != null) { setRestErrorHandlerField(); setErrorHandlerMethod.body().assign(_this().ref(getRestErrorHandlerField()), setErrorHandlerMethod.params().get(0)); } }
private void implementSetRootUrl(List<ExecutableElement> methods) { JMethod setRootUrlMethod = codeModelHelper.implementMethod(this, methods, "setRootUrl", TypeKind.VOID.toString(), STRING); if (setRootUrlMethod != null) { setRootUrlMethod.body().assign(_this().ref(getRootUrlField()), setRootUrlMethod.params().get(0)); } }
private void implementSetRestTemplate(List<ExecutableElement> methods) { JMethod setRestTemplateMethod = codeModelHelper.implementMethod(this, methods, null, TypeKind.VOID.toString(), REST_TEMPLATE); if (setRestTemplateMethod != null) { setRestTemplateMethod.body().assign(_this().ref(getRestTemplateField()), setRestTemplateMethod.params().get(0)); } }
private void implementSetBasicAuth(List<ExecutableElement> methods) { JMethod setAuthMethod = codeModelHelper.implementMethod(this, methods, "setHttpBasicAuth", TypeKind.VOID.toString(), STRING, STRING); if (setAuthMethod != null) { AbstractJClass basicAuthClass = getJClass(HTTP_BASIC_AUTHENTICATION); JInvocation basicAuthentication = JExpr._new(basicAuthClass).arg(setAuthMethod.params().get(0)).arg(setAuthMethod.params().get(1)); setAuthMethod.body().assign(_this().ref(getAuthenticationField()), basicAuthentication); } }
private void implementSetBearerAuth(List<ExecutableElement> methods) { JMethod setBearerMethod = codeModelHelper.implementMethod(this, methods, "setBearerAuth", TypeKind.VOID.toString(), true, STRING); if (setBearerMethod != null) { JVar tokenParamVar = setBearerMethod.params().get(0); IJExpression tokenExpr = lit("Bearer ").plus(tokenParamVar); AbstractJClass authClass = getJClass(HTTP_AUTHENTICATION); JDefinedClass anonymousHttpAuthClass = getCodeModel().anonymousClass(authClass); JMethod getHeaderValueMethod = anonymousHttpAuthClass.method(JMod.PUBLIC, String.class, "getHeaderValue"); getHeaderValueMethod.annotate(Override.class); JBlock getHeaderValueMethodBody = getHeaderValueMethod.body(); getHeaderValueMethodBody._return(tokenExpr); JBlock setBearerBody = setBearerMethod.body(); setBearerBody.assign(_this().ref(getAuthenticationField()), _new(anonymousHttpAuthClass)); } }
public JMethod implementMethod(GeneratedClassHolder holder, List<ExecutableElement> methods, String methodName, String returnType, String... parameterTypes) { return implementMethod(holder, methods, methodName, returnType, false, parameterTypes); }