@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 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 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() { 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 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 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 String getDescription() { //we'll return a description if all descriptions of all methods are the same, or if there's only one defining controller. String description = null; Set<SpringController> definingResourceClasses = new TreeSet<SpringController>(new TypeElementComparator()); int methodCount = 0; RESOURCES : for (Resource resource : this.resources) { for (Method method : resource.getMethods()) { methodCount++; if (description != null && method.getDescription() != null && !description.equals(method.getDescription())){ description = null; break RESOURCES; } description = method.getDescription(); if (description != null && description.trim().isEmpty()) { description = null; } } if (resource instanceof ResourceImpl) { definingResourceClasses.add(((ResourceImpl) resource).requestMapping.getParent()); } } if ((methodCount > 1 || description == null) && definingResourceClasses.size() == 1) { description = definingResourceClasses.iterator().next().getDocValue(); } return description; }
@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).getRequestMapping().getSimpleName().toString()) && ((MethodImpl)method).getRequestMapping().getParent().getQualifiedName().contentEquals(classname)) { return method; } } } } } return null; }
@Override public String getDescription() { if (this.description != null) { return this.description; } //we'll return a description if all descriptions of all methods are the same, or if there's only one defining resource class. String description = null; Set<com.webcohesion.enunciate.modules.jaxrs.model.Resource> definingResourceClasses = new TreeSet<com.webcohesion.enunciate.modules.jaxrs.model.Resource>(new TypeElementComparator()); int methodCount = 0; RESOURCES : for (Resource resource : this.resources) { for (Method method : resource.getMethods()) { methodCount++; if (description != null && method.getDescription() != null && !description.equals(method.getDescription())){ description = null; break RESOURCES; } description = method.getDescription(); if (description != null && description.trim().isEmpty()) { description = null; } } if (resource instanceof ResourceImpl) { definingResourceClasses.add(((ResourceImpl) resource).resourceMethod.getParent()); } } if ((methodCount > 1 || description == null) && definingResourceClasses.size() == 1) { description = definingResourceClasses.iterator().next().getDocValue(); } return description; }
@Override public String getDescription() { //we'll return a description if all descriptions of all methods are the same, or if there's only one defining resource class. String description = null; Set<com.webcohesion.enunciate.modules.jaxrs.model.Resource> definingResourceClasses = new TreeSet<com.webcohesion.enunciate.modules.jaxrs.model.Resource>(new TypeElementComparator()); int methodCount = 0; RESOURCES : for (Resource resource : this.resources) { for (Method method : resource.getMethods()) { methodCount++; if (description != null && method.getDescription() != null && !description.equals(method.getDescription())){ description = null; break RESOURCES; } description = method.getDescription(); if (description != null && description.trim().isEmpty()) { description = null; } } if (resource instanceof ResourceImpl) { definingResourceClasses.add(((ResourceImpl) resource).resourceMethod.getParent()); } } if ((methodCount > 1 || description == null) && definingResourceClasses.size() == 1) { //if there's only one class, it's javadoc is probably a better description than the method-level. description = definingResourceClasses.iterator().next().getDocValue(); } return description; }
@Override public String getDescription() { if (this.description == null) { return this.description; } //we'll return a description if all descriptions of all methods are the same, or if there's only one defining controller. String description = null; Set<SpringController> definingResourceClasses = new TreeSet<SpringController>(new TypeElementComparator()); int methodCount = 0; RESOURCES : for (Resource resource : this.resources) { for (Method method : resource.getMethods()) { methodCount++; if (description != null && method.getDescription() != null && !description.equals(method.getDescription())){ description = null; break RESOURCES; } description = method.getDescription(); if (description != null && description.trim().isEmpty()) { description = null; } } if (resource instanceof ResourceImpl) { definingResourceClasses.add(((ResourceImpl) resource).requestMapping.getParent()); } } if ((methodCount > 1 || description == null) && definingResourceClasses.size() == 1) { description = definingResourceClasses.iterator().next().getDocValue(); } return description; }
@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 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(resourceClass.getContext().getPathSortStrategy())); return pathSummaries; }
@Override public ResourceGroup findResourceGroupFor(String classname) { if (classname.isEmpty()) { return null; } for (ResourceGroup resourceGroup : getResourceGroups()) { for (Resource resource : resourceGroup.getResources()) { for (Method method : resource.getMethods()) { if (method instanceof MethodImpl) { if (((MethodImpl)method).getRequestMapping().getParent().getQualifiedName().contentEquals(classname)) { return resourceGroup; } } } } } return null; } }
public Object exec(List list) throws TemplateModelException { if (list.size() < 1) { throw new TemplateModelException("The uniqueMediaTypesFor method must have a parameter."); } TemplateModel from = (TemplateModel) list.get(0); Object unwrapped = new BeansWrapperBuilder(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS).build().unwrap(from); Map<String, Parameter> uniquePathParams = new HashMap<String, Parameter>(); if (unwrapped instanceof Resource) { Resource entity = (Resource) unwrapped; List<? extends Method> methods = entity.getMethods(); if (methods != null) { for (Method method : methods) { List<? extends Parameter> params = method.getParameters(); if (params != null) { for (Parameter param : params) { if (param.getTypeLabel().equals("path")) { uniquePathParams.put(param.getName(), param); } } } } } } return uniquePathParams.values(); } }
@Override public ResourceGroup findResourceGroupFor(String classname) { if (classname.isEmpty()) { return null; } for (ResourceGroup resourceGroup : getResourceGroups()) { for (Resource resource : resourceGroup.getResources()) { for (Method method : resource.getMethods()) { if (method instanceof MethodImpl) { if (((MethodImpl)method).getResourceMethod().getParent().getQualifiedName().contentEquals(classname)) { return resourceGroup; } } } } } return null; } }
public Object exec(List list) throws TemplateModelException { if (list.size() < 1) { throw new TemplateModelException("The uniqueMediaTypesFor method must have a parameter."); } TemplateModel from = (TemplateModel) list.get(0); Object unwrapped = new BeansWrapperBuilder(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS).build().unwrap(from); Map<String, Parameter> uniquePathParams = new HashMap<String, Parameter>(); if (unwrapped instanceof Resource) { Resource entity = (Resource) unwrapped; List<? extends Method> methods = entity.getMethods(); if (methods != null) { for (Method method : methods) { List<? extends Parameter> params = method.getParameters(); if (params != null) { for (Parameter param : params) { if (param.getTypeLabel().equals("path")) { uniquePathParams.put(param.getName(), param); } } } } } } return uniquePathParams.values(); } }
List<Resource> resources = resourceGroup.getResources(); for (Resource resource : resources) { for (Method method : resource.getMethods()) { if (hasXmlResponseEntity(method)) { if (hasXmlRequestEntity(method)) {
List<Resource> resources = resourceGroup.getResources(); for (Resource resource : resources) { for (Method method : resource.getMethods()) { if (hasXmlResponseEntity(method)) { if (hasXmlRequestEntity(method)) {