All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.hts.springwebdoclet.processors.impl.ThrowsProcessorImpl Maven / Gradle / Ivy

package ru.hts.springwebdoclet.processors.impl;

import com.sun.javadoc.*;
import org.apache.commons.lang3.StringUtils;
import ru.hts.springwebdoclet.processors.ThrowsProcessor;
import ru.hts.springwebdoclet.render.RenderContext;

import java.util.ArrayList;
import java.util.List;

/**
 * Processes exceptions which method throws
 * @author Ivan Sungurov
 */
public class ThrowsProcessorImpl implements ThrowsProcessor {
    @Override
    public void init(RootDoc rootDoc) {
    }

    @Override
    public List process(ClassDoc classDoc, MethodDoc methodDoc) {
        List result = new ArrayList();

        for (Tag tag : methodDoc.tags("throws")) {
            ThrowsTag throwsTag = (ThrowsTag) tag;
            RenderContext exception = new RenderContext();

            exception.put("type", throwsTag.exceptionName());

            ClassDoc exceptionClassDoc = classDoc.findClass(throwsTag.exceptionType().qualifiedTypeName());
            String description = StringUtils.isNotEmpty(throwsTag.exceptionComment()) ?
                    throwsTag.exceptionComment() :
                    exceptionClassDoc.commentText();
            exception.put("description", description);

            result.add(exception);
        }

        return result;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy