@Override public List<PathSummary> getPaths() { Set<String> methods = new TreeSet<String>(); Set<String> styles = new TreeSet<String>(); for (Resource resource : this.resources) { for (Method method : resource.getMethods()) { methods.add(method.getHttpMethod()); styles.addAll(method.getStyles()); } } return Collections.singletonList((PathSummary) new PathSummaryImpl(this.path, methods, styles)); }
@Override public List<PathSummary> getPaths() { HashMap<String, PathSummary> paths = new HashMap<String, PathSummary>(); for (Resource resource : this.resources) { PathSummary pathSummary = paths.get(resource.getPath()); if (pathSummary == null) { pathSummary = new PathSummaryImpl(resource.getPath(), new TreeSet<String>(), resource.getStyles()); paths.put(resource.getPath(), pathSummary); } for (Method method : resource.getMethods()) { pathSummary.getMethods().add(method.getHttpMethod()); } } ArrayList<PathSummary> pathSummaries = new ArrayList<PathSummary>(paths.values()); Collections.sort(pathSummaries, new PathSummaryComparator(sortStrategy)); return pathSummaries; }
@Override public String getDeprecated() { String deprecated = null; for (Resource resource : this.resources) { deprecated = resource.getDeprecated(); if (deprecated == null) { //if _any_ resources are not deprecated, this resource group isn't deprecated either. return null; } } return deprecated; }
@Override public int compare(Resource g1, Resource g2) { int compare = pathComparator.compare(g1.getPath(), g2.getPath()); if (compare == 0) { List<? extends Method> m1 = g1.getMethods(); List<? extends Method> m2 = g2.getMethods(); if (m1.size() == 1 && m2.size() == 1) { compare = (m1.get(0).getHttpMethod().compareTo(m2.get(0).getHttpMethod())); } } return compare; } }
model.put("resource_url", exampleResource.getResource().getPath()); model.put("resource_method", exampleResource.getHttpMethod());
@Override public Set<Facet> getFacets() { TreeSet<Facet> facets = new TreeSet<Facet>(); for (Resource resource : this.resources) { facets.addAll(resource.getFacets()); } return facets; }
@Override public Set<String> getStyles() { TreeSet<String> styles = new TreeSet<String>(); for (Resource resource : this.resources) { styles.addAll(resource.getStyles()); } return styles; } }
@Override public int compare(Resource g1, Resource g2) { int compare = pathComparator.compare(g1.getPath(), g2.getPath()); if (compare == 0) { List<? extends Method> m1 = g1.getMethods(); List<? extends Method> m2 = g2.getMethods(); if (m1.size() == 1 && m2.size() == 1) { compare = (m1.get(0).getHttpMethod().compareTo(m2.get(0).getHttpMethod())); } } return compare; } }
@Override public Set<Facet> getFacets() { TreeSet<Facet> facets = new TreeSet<Facet>(); for (Resource resource : this.resources) { facets.addAll(resource.getFacets()); } return facets; }
@Override public Set<String> getStyles() { TreeSet<String> styles = new TreeSet<String>(); for (Resource resource : this.resources) { styles.addAll(resource.getStyles()); } return styles; } }
@Override public List<PathSummary> getPaths() { Set<String> methods = new TreeSet<String>(); Set<String> styles = new TreeSet<String>(); for (Resource resource : this.resources) { for (Method method : resource.getMethods()) { methods.add(method.getHttpMethod()); styles.addAll(method.getStyles()); } } return Arrays.asList((PathSummary) new PathSummaryImpl(this.path, methods, styles)); }
@Override public List<PathSummary> getPaths() { HashMap<String, PathSummary> paths = new HashMap<String, PathSummary>(); for (Resource resource : this.resources) { PathSummary pathSummary = paths.get(resource.getPath()); if (pathSummary == null) { pathSummary = new PathSummaryImpl(resource.getPath(), new TreeSet<String>(), resource.getStyles()); paths.put(resource.getPath(), pathSummary); } for (Method method : resource.getMethods()) { pathSummary.getMethods().add(method.getHttpMethod()); } } ArrayList<PathSummary> pathSummaries = new ArrayList<PathSummary>(paths.values()); Collections.sort(pathSummaries, new PathSummaryComparator(sortStrategy)); return pathSummaries; }
@Override public String getDeprecated() { String deprecated = null; for (Resource resource : this.resources) { deprecated = resource.getDeprecated(); if (deprecated == null) { //if _any_ resources are not deprecated, this resource group isn't deprecated either. return null; } } return deprecated; }
@Override public Set<Facet> getFacets() { TreeSet<Facet> facets = new TreeSet<Facet>(); for (Resource resource : this.resources) { facets.addAll(resource.getFacets()); } return facets; }
@Override public Set<String> getStyles() { TreeSet<String> styles = new TreeSet<String>(); for (Resource resource : this.resources) { styles.addAll(resource.getStyles()); } return styles; } }
@Override public Method findMethodFor(String classname, String methodname) { if (methodname.isEmpty() || classname.isEmpty()) { return null; } for (ResourceGroup resourceGroup : getResourceGroups()) { for (Resource resource : resourceGroup.getResources()) { for (Method method : resource.getMethods()) { if (method instanceof MethodImpl) { if (methodname.startsWith(((MethodImpl) method).getResourceMethod().getSimpleName().toString()) && ((MethodImpl)method).getResourceMethod().getParent().getQualifiedName().contentEquals(classname)) { return method; } } } } } return null; }
@Override public List<PathSummary> getPaths() { HashMap<String, PathSummary> summaries = new HashMap<String, PathSummary>(); for (Resource resource : this.resources) { Set<String> methods = new TreeSet<String>(); for (Method method : resource.getMethods()) { methods.add(method.getHttpMethod()); } PathSummary summary = summaries.get(resource.getPath()); if (summary == null) { summary = new PathSummaryImpl(resource.getPath(), methods, resource.getStyles()); summaries.put(resource.getPath(), summary); } else { summary.getMethods().addAll(methods); } } ArrayList<PathSummary> pathSummaries = new ArrayList<PathSummary>(summaries.values()); Collections.sort(pathSummaries, new PathSummaryComparator(controllerClass.getContext().getPathSortStrategy())); return pathSummaries; }
@Override public String getDeprecated() { String deprecated = null; for (Resource resource : this.resources) { deprecated = resource.getDeprecated(); if (deprecated == null) { //if _any_ resources are not deprecated, this resource group isn't deprecated either. return null; } } return deprecated; }
@Override public Set<Facet> getFacets() { TreeSet<Facet> facets = new TreeSet<Facet>(); for (Resource resource : this.resources) { facets.addAll(resource.getFacets()); } return facets; }
@Override public Set<String> getStyles() { TreeSet<String> styles = new TreeSet<String>(); for (Resource resource : this.resources) { styles.addAll(resource.getStyles()); } return styles; } }