use of com.luojilab.router.facade.annotation.RouteNode in project ChidoriX by Chihiro23333.
the class RouterProcessor method parseRouteNodes.
private void parseRouteNodes(Set<? extends Element> routeElements) {
TypeMirror type_Activity = elements.getTypeElement(ACTIVITY).asType();
for (Element element : routeElements) {
TypeMirror tm = element.asType();
RouteNode route = element.getAnnotation(RouteNode.class);
if (types.isSubtype(tm, type_Activity)) {
// Activity
logger.info(">>> Found activity route: " + tm.toString() + " <<<");
Node node = new Node();
String path = route.path();
checkPath(path);
node.setPath(path);
node.setDesc(route.desc());
node.setPriority(route.priority());
node.setNodeType(NodeType.ACTIVITY);
node.setRawType(element);
Map<String, Integer> paramsType = new HashMap<>();
Map<String, String> paramsDesc = new HashMap<>();
for (Element field : element.getEnclosedElements()) {
if (field.getKind().isField() && field.getAnnotation(Autowired.class) != null) {
Autowired paramConfig = field.getAnnotation(Autowired.class);
paramsType.put(StringUtils.isEmpty(paramConfig.name()) ? field.getSimpleName().toString() : paramConfig.name(), typeUtils.typeExchange(field));
paramsDesc.put(StringUtils.isEmpty(paramConfig.name()) ? field.getSimpleName().toString() : paramConfig.name(), typeUtils.typeDesc(field));
}
}
node.setParamsType(paramsType);
node.setParamsDesc(paramsDesc);
if (!routerNodes.contains(node)) {
routerNodes.add(node);
}
} else {
throw new IllegalStateException("only activity can be annotated by RouteNode");
}
}
}
Aggregations