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

org.apache.maven.model.Build 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 Build
    extends BuildBase
    implements Serializable, Cloneable
{

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

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

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

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

    @Override
    public org.apache.maven.api.model.Build getDelegate() {
        return (org.apache.maven.api.model.Build) super.getDelegate();
    }

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

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

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

    public void setSourceDirectory(String sourceDirectory) {
        if (!Objects.equals(sourceDirectory, getSourceDirectory())) {
            update(getDelegate().withSourceDirectory(sourceDirectory));
        }
    }

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

    public void setScriptSourceDirectory(String scriptSourceDirectory) {
        if (!Objects.equals(scriptSourceDirectory, getScriptSourceDirectory())) {
            update(getDelegate().withScriptSourceDirectory(scriptSourceDirectory));
        }
    }

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

    public void setTestSourceDirectory(String testSourceDirectory) {
        if (!Objects.equals(testSourceDirectory, getTestSourceDirectory())) {
            update(getDelegate().withTestSourceDirectory(testSourceDirectory));
        }
    }

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

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

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

    public void setTestOutputDirectory(String testOutputDirectory) {
        if (!Objects.equals(testOutputDirectory, getTestOutputDirectory())) {
            update(getDelegate().withTestOutputDirectory(testOutputDirectory));
        }
    }

    @Nonnull
    public List getExtensions() {
        return new WrapperList(
                    () -> getDelegate().getExtensions(), l -> update(getDelegate().withExtensions(l)),
                    d -> new Extension(d, this), Extension::getDelegate);
    }

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

    public void addExtension(Extension extension) {
        update(getDelegate().withExtensions(
               Stream.concat(getDelegate().getExtensions().stream(), Stream.of(extension.getDelegate()))
                        .collect(Collectors.toList())));
        extension.childrenTracking = this::replace;
    }

    public void removeExtension(Extension extension) {
        update(getDelegate().withExtensions(
               getDelegate().getExtensions().stream()
                        .filter(e -> !Objects.equals(e, extension))
                        .collect(Collectors.toList())));
        extension.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.Build.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.Build.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().getExtensions().contains(oldDelegate)) {
            List list = new ArrayList<>(getDelegate().getExtensions());
            list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.Extension) newDelegate : d);
            update(getDelegate().withExtensions(list));
            return true;
        }
        return false;
    }

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

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


            
    /**
     * @see java.lang.Object#toString()
     */
    public String toString()
    {
        return "Build {" + super.toString() + "}";
    }
            
          
}