public final Set<T> findAsComponents() { return ImmutableSet.copyOf( Iterables.transform(find(), NamedComponent.<T>toComponent())); } public abstract Set<Name<T>> findNames();
@Override protected Set<NamedComponent<T>> doFind() { Set<NamedComponent<T>> components = Sets.newTreeSet(NAMED_COMPONENT_COMPARATOR); Factory factory = factory(); for (Name<T> tName : factory.collectAllBuildableNames(componentClass)) { components.addAll(factory.queryByName(tName).optional().find()); } return components; }
private List<ImmutableMap<String, String>> buildApis() { Set<NamedComponent<RestxRouter>> routers = factory.queryByClass(RestxRouter.class).find(); List<ImmutableMap<String, String>> apis = Lists.newArrayList(); for (NamedComponent<RestxRouter> router : routers) { String routerApiPath = getRouterApiPath(router.getName().getName()); if (ApiDeclarationRoute.getRouterByName(factory, routerApiPath).isPresent()) { // we add the api only if we can find back the router from the name, otherwise it will trigger // 404 errors in API-DOCS apis.add(ImmutableMap.of( "path", "/@/api-docs/" + routerApiPath, "name", routerApiPath, "group", router.getComponent().getGroupName(), "description", "")); } } return apis; }
private Multimap<String, OperationReference> getOperationReferencesByType() { Multimap<String, OperationReference> operationsByType = ArrayListMultimap.create(); Set<NamedComponent<RestxRouter>> routers = factory.queryByClass(RestxRouter.class).find(); for (NamedComponent<RestxRouter> r : routers) { String routerApiPath = getRouterApiPath(r.getName().getName()); for (ResourceDescription resourceDescription : describeAllRoutes(r.getComponent())) { for (OperationDescription operation : resourceDescription.operations) { OperationReference ref = buildReferenceFor(routerApiPath, resourceDescription.path, operation); addIfRelevant(operationsByType, ref, operation.responseClass); Optional<OperationParameterDescription> bodyParameter = operation.findBodyParameter(); if (bodyParameter.isPresent()) { addIfRelevant(operationsByType, ref, bodyParameter.get().dataType); } } } } return operationsByType; }
private Multimap<String, OperationReference> getOperationReferencesByType() { Multimap<String, OperationReference> operationsByType = ArrayListMultimap.create(); Set<NamedComponent<RestxRouter>> routers = factory.queryByClass(RestxRouter.class).find(); for (NamedComponent<RestxRouter> r : routers) { String routerApiPath = getRouterApiPath(r.getName().getName()); for (ResourceDescription resourceDescription : describeAllRoutes(r.getComponent())) { for (OperationDescription operation : resourceDescription.operations) { OperationReference ref = buildReferenceFor(routerApiPath, resourceDescription.path, operation); addIfRelevant(operationsByType, ref, operation.responseClass); Optional<OperationParameterDescription> bodyParameter = operation.findBodyParameter(); if (bodyParameter.isPresent()) { addIfRelevant(operationsByType, ref, bodyParameter.get().dataType); } } } } return operationsByType; }
private List<ImmutableMap<String, String>> buildApis() { Set<NamedComponent<RestxRouter>> routers = factory.queryByClass(RestxRouter.class).find(); List<ImmutableMap<String, String>> apis = Lists.newArrayList(); for (NamedComponent<RestxRouter> router : routers) { String routerApiPath = getRouterApiPath(router.getName().getName()); if (ApiDeclarationRoute.getRouterByName(factory, routerApiPath).isPresent()) { // we add the api only if we can find back the router from the name, otherwise it will trigger // 404 errors in API-DOCS apis.add(ImmutableMap.of( "path", "/@/api-docs/" + routerApiPath, "name", routerApiPath, "group", router.getComponent().getGroupName(), "description", "")); } } return apis; }
private Multimap<String, OperationReference> getOperationReferencesByPath() { Multimap<String, OperationReference> operationsByPath = ArrayListMultimap.create(); Set<NamedComponent<RestxRouter>> routers = factory.queryByClass(RestxRouter.class).find(); for (NamedComponent<RestxRouter> r : routers) { String routerApiPath = getRouterApiPath(r.getName().getName()); for (ResourceDescription resourceDescription : describeAllRoutes(r.getComponent())) { for (OperationDescription operation : resourceDescription.operations) { OperationReference ref = buildReferenceFor(routerApiPath, resourceDescription.path, operation); operationsByPath.put(resourceDescription.path, ref); } } } return operationsByPath; }
private Multimap<String, OperationReference> getOperationReferencesByPath() { Multimap<String, OperationReference> operationsByPath = ArrayListMultimap.create(); Set<NamedComponent<RestxRouter>> routers = factory.queryByClass(RestxRouter.class).find(); for (NamedComponent<RestxRouter> r : routers) { String routerApiPath = getRouterApiPath(r.getName().getName()); for (ResourceDescription resourceDescription : describeAllRoutes(r.getComponent())) { for (OperationDescription operation : resourceDescription.operations) { OperationReference ref = buildReferenceFor(routerApiPath, resourceDescription.path, operation); operationsByPath.put(resourceDescription.path, ref); } } } return operationsByPath; }