Search in sources :

Example 1 with TypeElementComparator

use of com.webcohesion.enunciate.javac.TypeElementComparator in project enunciate by stoicflame.

the class PathBasedResourceGroupImpl method getDescription.

@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;
}
Also used : TypeElementComparator(com.webcohesion.enunciate.javac.TypeElementComparator) Resource(com.webcohesion.enunciate.api.resources.Resource) Method(com.webcohesion.enunciate.api.resources.Method)

Example 2 with TypeElementComparator

use of com.webcohesion.enunciate.javac.TypeElementComparator in project enunciate by stoicflame.

the class AnnotationBasedResourceGroupImpl method getDescription.

@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;
}
Also used : TypeElementComparator(com.webcohesion.enunciate.javac.TypeElementComparator) Resource(com.webcohesion.enunciate.api.resources.Resource) Method(com.webcohesion.enunciate.api.resources.Method)

Example 3 with TypeElementComparator

use of com.webcohesion.enunciate.javac.TypeElementComparator in project enunciate by stoicflame.

the class AnnotationBasedResourceGroupImpl method getDescription.

@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;
}
Also used : TypeElementComparator(com.webcohesion.enunciate.javac.TypeElementComparator) Resource(com.webcohesion.enunciate.api.resources.Resource) Method(com.webcohesion.enunciate.api.resources.Method) SpringController(com.webcohesion.enunciate.modules.spring_web.model.SpringController)

Example 4 with TypeElementComparator

use of com.webcohesion.enunciate.javac.TypeElementComparator in project enunciate by stoicflame.

the class PathBasedResourceGroupImpl method getDescription.

@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;
}
Also used : TypeElementComparator(com.webcohesion.enunciate.javac.TypeElementComparator) Resource(com.webcohesion.enunciate.api.resources.Resource) Method(com.webcohesion.enunciate.api.resources.Method) SpringController(com.webcohesion.enunciate.modules.spring_web.model.SpringController)

Aggregations

Method (com.webcohesion.enunciate.api.resources.Method)4 Resource (com.webcohesion.enunciate.api.resources.Resource)4 TypeElementComparator (com.webcohesion.enunciate.javac.TypeElementComparator)4 SpringController (com.webcohesion.enunciate.modules.spring_web.model.SpringController)2