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

org.apache.maven.model.Reporting Maven / Gradle / Ivy

The newest version!
// =================== DO NOT EDIT THIS FILE ====================
//  Generated by Modello Velocity from model-v3.vm
//  template, any modifications will be overwritten.
// ==============================================================
package org.apache.maven.model;

import java.io.Serializable;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.maven.api.annotations.Generated;
import org.apache.maven.api.annotations.Nonnull;

@Generated
public class Reporting
    extends BaseObject
{

    public Reporting() {
        this(org.apache.maven.api.model.Reporting.newInstance());
    }

    public Reporting(org.apache.maven.api.model.Reporting delegate) {
        this(delegate, null);
    }

    public Reporting(org.apache.maven.api.model.Reporting delegate, BaseObject parent) {
        super(delegate, parent);
    }

    public Reporting clone(){
        return new Reporting(getDelegate());
    }

    public org.apache.maven.api.model.Reporting getDelegate() {
        return (org.apache.maven.api.model.Reporting) super.getDelegate();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || !(o instanceof Reporting)) {
            return false;
        }
        Reporting that = (Reporting) o;
        return Objects.equals(this.delegate, that.delegate);
    }

    @Override
    public int hashCode() {
        return getDelegate().hashCode();
    }

    public String getExcludeDefaults() {
        return getDelegate().getExcludeDefaults();
    }

    public void setExcludeDefaults(String excludeDefaults) {
        if (!Objects.equals(excludeDefaults, getExcludeDefaults())) {
            update(getDelegate().withExcludeDefaults(excludeDefaults));
        }
    }

    public String getOutputDirectory() {
        return getDelegate().getOutputDirectory();
    }

    public void setOutputDirectory(String outputDirectory) {
        if (!Objects.equals(outputDirectory, getOutputDirectory())) {
            update(getDelegate().withOutputDirectory(outputDirectory));
        }
    }

    @Nonnull
    public List getPlugins() {
        return new WrapperList(
                    () -> getDelegate().getPlugins(), l -> update(getDelegate().withPlugins(l)),
                    d -> new ReportPlugin(d, this), ReportPlugin::getDelegate);
    }

    public void setPlugins(List plugins) {
        if (plugins == null) {
            plugins = Collections.emptyList();
        }
        if (!Objects.equals(plugins, getPlugins())) {
            update(getDelegate().withPlugins(
                plugins.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
            plugins.forEach(e -> e.childrenTracking = this::replace);
        }
    }

    public void addPlugin(ReportPlugin plugin) {
        update(getDelegate().withPlugins(
               Stream.concat(getDelegate().getPlugins().stream(), Stream.of(plugin.getDelegate()))
                        .collect(Collectors.toList())));
        plugin.childrenTracking = this::replace;
    }

    public void removePlugin(ReportPlugin plugin) {
        update(getDelegate().withPlugins(
               getDelegate().getPlugins().stream()
                        .filter(e -> !Objects.equals(e, plugin))
                        .collect(Collectors.toList())));
        plugin.childrenTracking = null;
    }

    public InputLocation getLocation(Object key) {
        org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation(key);
        return loc != null ? new InputLocation(loc) : null;
    }

    public void setLocation(Object key, InputLocation location) {
        update(org.apache.maven.api.model.Reporting.newBuilder(getDelegate(), true)
                        .location(key, location.toApiLocation()).build());
    }

    public InputLocation getImportedFrom() {
        org.apache.maven.api.model.InputLocation loc = getDelegate().getImportedFrom();
        return loc != null ? new InputLocation(loc) : null;
    }

    public void setImportedFrom(InputLocation location) {
        update(org.apache.maven.api.model.Reporting.newBuilder(getDelegate(), true)
                        .importedFrom(location.toApiLocation()).build());
    }

    public Set getLocationKeys() {
        return getDelegate().getLocationKeys();
    }

    protected boolean replace(Object oldDelegate, Object newDelegate) {
        if (super.replace(oldDelegate, newDelegate)) {
            return true;
        }
        if (getDelegate().getPlugins().contains(oldDelegate)) {
            List list = new ArrayList<>(getDelegate().getPlugins());
            list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.ReportPlugin) newDelegate : d);
            update(getDelegate().withPlugins(list));
            return true;
        }
        return false;
    }

    public static List reportingToApiV4(List list) {
        return list != null ? new WrapperList<>(list, Reporting::getDelegate, Reporting::new) : null;
    }

    public static List reportingToApiV3(List list) {
        return list != null ? new WrapperList<>(list, Reporting::new, Reporting::getDelegate) : null;
    }


            
    public boolean isExcludeDefaults() {
        return (getExcludeDefaults() != null) ? Boolean.parseBoolean(getExcludeDefaults()) : false;
    }

            
          

            
    public void setExcludeDefaults(boolean excludeDefaults) {
        setExcludeDefaults(String.valueOf(excludeDefaults));
    }

    /**
     * Reset the reportPluginMap field to null
     */
    @Deprecated
    public void flushReportPluginMap() {
    }

    /**
     * @return a Map of plugins field with ReportPlugin#getKey() as key
     * @see org.apache.maven.model.ReportPlugin#getKey()
     */
    public java.util.Map getReportPluginsAsMap() {
        return getPlugins().stream().collect(Collectors.toMap(report -> report.getKey(), report -> report));
    }
            
          
}