public String getNameWithPrefix(String prefix) { if (StringUtils.isEmpty(prefix)) { return getName(); } return StrUtils.addPrefix(prefix, getName()); }
@Override public final <M> HtmlResponse render(String templatePath, M model) { String templateFullPath; if (StringUtils.startsWith(templatePath, "/")) { templateFullPath = templatePath; } else if (StringUtils.startsWith(templatePath, ".")) { templateFullPath = StrUtils.concatPath(templatesRootPath, templatePath.substring(1), "/"); } else { templateFullPath = StrUtils.concatPath(templatesRootPath, templatePath, "/"); } String html = doRender(templateFullPath, model); return new HtmlResponse(html); }
protected String toProducerClassSimpleName(String rank) { String normalized = Normalizer.normalize(rank, Normalizer.Form.NFD); String rankToName = normalized.replaceAll("[^A-Za-z0-9]", ""); rankToName = StrUtils.firstCharToUpperCase(rankToName); String indStr = ""; if (producerIndex > 0) { indStr = Integer.toString(producerIndex); } String simpleClassName = "Config" + rankToName + indStr + "Producer"; producerIndex++; return simpleClassName; }
protected String buildMethodRoute(TeleMethodElement teleMethod) { AnnotationElement<Route> routeAnnotation = teleMethod.getProxyMethod().getOriginMethod().getAnnotation(Route.class); String methodRoute; if (routeAnnotation == null) { methodRoute = RouteTrie.SEGMENT_DELEMITER + StrUtils.toLowerCaseNotation(teleMethod.getName()); } else { methodRoute = routeAnnotation.unwrap().value(); } if (methodRoute.equals(RouteTrie.SEGMENT_DELEMITER)) { methodRoute = ""; } HttpMethod httpMethod = HttpMethod.GET; AnnotationElement<RequestMethod> methodAnnotation = teleMethod.getProxyMethod().getOriginMethod().getAnnotation(RequestMethod.class); if (methodAnnotation != null) { httpMethod = methodAnnotation.unwrap().value(); } String result = StrUtils.concatPath(httpMethod.name(), framletRoute, RouteTrie.SEGMENT_DELEMITER); result = StrUtils.concatPath(result, methodRoute, RouteTrie.SEGMENT_DELEMITER); return result; }
if (StringUtils.isBlank(beanRouteValue)){ String classSimpleName = framlet.getOriginClass().getSimpleName().toString(); beanRouteValue = "/"+ StrUtils.toLowerCaseNotation(classSimpleName); return StrUtils.concatPath(pkgRouteValue, beanRouteValue, RouteTrie.SEGMENT_DELEMITER); } else { throw CodegenException.of() } else { String classSimpleName = framlet.getOriginClass().getSimpleName().toString(); return "/" + StrUtils.toLowerCaseNotation(classSimpleName);
public String getNameWithPrefix(String prefix) { if (StringUtils.isEmpty(prefix)) { return getName(); } return StrUtils.addPrefix(prefix, getName()); }
public String getClassSimpleName() { return parentService.getOriginClass().getSimpleName().toString() + StrUtils.firstCharToUpperCase(teleType); }
@Override public void perform(HttpMethod httpMethod, String uri) { RouteTrie.RouteResolution<TeleMethod> routeResolution = routeTrie.resolveRoute(StrUtils.concatPath(httpMethod.name(), uri, RouteTrie.SEGMENT_DELEMITER)); if (routeResolution == null) { throw new UnknownRouteException(uri, httpMethod); } TeleMethod telemethod = routeResolution.getNode().getValue(); if (telemethod == null) { throw new UnknownRouteException(uri, httpMethod); } RouterContext routerContext = new RouterContext(uri, routeResolution.getParams()); threadScope.put(RouterContext.SCOPE_KEY, routerContext); telemethod.invoke(); } }
protected void generateInvocationContextExec(MethodElement methodElement, MethodSpec.Builder proxyMethodBuilder) { List<ParameterElement> methodParams = methodElement.getParameters(); List<String> paramNames = new ArrayList<>(); for (ParameterElement paramElm : methodParams) { paramNames.add(StrUtils.addPrefix(METHOD_PARAM_PREFIX, paramElm.getName())); } String paramsArrayLiteral = "{" + String.join(",", paramNames) + "}"; proxyMethodBuilder.addStatement("final $T " + INV_CONTEXT_VARIABLE + "=new $T(this,$S,new $T[]$L," + INTERCEPTORS_CHAIN_VARIABLE + ")", ClassName.get(InvocationContext.class), ClassName.get(InvocationContext.class), methodElement.getName(), ArrayTypeName.get(Object.class), paramsArrayLiteral); TypeMirror returnType = methodElement.getReturnType(); boolean voidResult = returnType instanceof NoType; if (voidResult) { proxyMethodBuilder.addStatement(INV_CONTEXT_VARIABLE + "." + InvocationContext.PROCEED_METHOD + "()"); } else { proxyMethodBuilder.addStatement("return ($T)" + INV_CONTEXT_VARIABLE + "." + InvocationContext.PROCEED_METHOD + "()", TypeName.get(methodElement.getReturnType())); } }
String setterName = "set" + StrUtils.firstCharToUpperCase(subvar.getOriginVariable().getName()); binderBuilder.add("$N.$N(", valueVar, setterName); binderBuilder.add(value);
constructorBuilder.addStatement("this.$N=$N", fieldElm.getSpec().name, fieldElm.getSpec().name); } else { String paramName = StrUtils.addPrefix(METHOD_PARAM_PREFIX, similarParam.getName()); constructorBuilder.addStatement("this.$N=$N", fieldElm.getSpec().name, paramName);