/*
 * Copyright 2009 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gradle.api.reporting;

import org.gradle.api.Namer;
import org.gradle.util.Configurable;

import java.io.File;
import java.io.Serializable;

/**
 * A file based report to be created.
 */
public interface Report extends Serializable, Configurable<Report> {
    
    Namer<Report> NAMER = new Namer<Report>() {
        public String determineName(Report report) {
            return report.getName();
        }
    };

    /**
     * The symbolic name of this report.
     *
     * The name of the report usually indicates the format (e.g. xml, html etc.) but can be anything.
     *
     * When part of a {@link ReportContainer}, reports are accessed via their name. That is, given a report container variable
     * named {@code reports} containing a report who's {@code getName()} returns {@code "html"}, the report could be accessed
     * via:
     *
     * <pre>
     * reports.html
     * </pre>
     *
     * @return The name of this report.
     */
    String getName();

    /**
     * Whether or not this report should be generated by whatever generates it.
     *
     * If {@code true}, the generator of this report will generate it at the appropriate time.
     * If {@code false}, the generator of this report will not generate this report.
     *
     * @return Whether or not this report should be generated by whatever generates it.
     */
    boolean isEnabled();

    /**
     * Whether or not this report should be generated by whatever generates it.
     *
     * @see #isEnabled()
     * @param enabled Whether or not this report should be generated by whatever generates it.
     */
    void setEnabled(boolean enabled);

    /**
     * The location on the filesystem of the report when it is generated.
     *
     * Depending on the {@link #getOutputType() output type} of the report, this may point to
     * a file or a directory.
     *
     * Subtypes may implement setters for the destination.
     *
     * @return The location on the filesystem of the report when it is generated
     */
    File getDestination();

    /**
     * The type of output the report produces
     */
    enum OutputType {

        /**
         * The report outputs a single file.
         *
         * That is, the {@link #getDestination()} file points a single file.
         */
        FILE,

        /**
         * The report outputs files into a directory.
         *
         * That is, the {@link #getDestination()} file points to a directory.
         */
        DIRECTORY
    }

    /**
     * The type of output that the report generates.
     *
     * @return The type of output that the report generates.
     */
    OutputType getOutputType();

}
