public String getComment()

in apache-rat-tools/src/main/java/org/apache/rat/tools/AntOption.java [225:259]


    public String getComment(final boolean addParam) {
        StringBuilder sb = new StringBuilder();
        String desc = getDescription();
        if (desc == null) {
            throw new IllegalStateException(format("Description for %s may not be null", getName()));
        }
        if (!desc.contains(".")) {
            throw new IllegalStateException(format("First sentence of description for %s must end with a '.'", getName()));
        }
        if (addParam) {
            String arg;
            if (option.hasArg()) {
                arg = desc.substring(desc.indexOf(" ") + 1, desc.indexOf(".") + 1);
                arg = WordUtils.capitalize(arg.substring(0, 1)) + arg.substring(1);
            } else {
                arg = "The state";
            }
            if (option.getArgName() != null) {
                Supplier<String> sup = OptionCollection.getArgumentTypes().get(option.getArgName());
                if (sup == null) {
                    throw new IllegalStateException(format("Argument type %s must be in OptionCollection.ARGUMENT_TYPES", option.getArgName()));
                }
                desc = format("%s Argument%s should be %s%s. (See Argument Types for clarification)", desc, option.hasArgs() ? "s" : "",
                        option.hasArgs() ? "" : "a ", option.getArgName());
            }
            sb.append(format("    /**%n     * %s%n     * @param %s %s%n", StringEscapeUtils.escapeHtml4(desc), getName(),
                    StringEscapeUtils.escapeHtml4(arg)));
        } else {
            sb.append(format("    /**%n     * %s%n", StringEscapeUtils.escapeHtml4(desc)));
        }
        if (option.isDeprecated()) {
            sb.append(format("     * @deprecated %s%n", StringEscapeUtils.escapeHtml4(getDeprecated())));
        }
        return sb.append(format("     */%n")).toString();
    }