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

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

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

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

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

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

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

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

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

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

    public void setDefaultGoal(String defaultGoal) {
        if (!Objects.equals(defaultGoal, getDefaultGoal())) {
            update(getDelegate().withDefaultGoal(defaultGoal));
        }
    }

    @Nonnull
    public List getResources() {
        return new WrapperList(
                    () -> getDelegate().getResources(), l -> update(getDelegate().withResources(l)),
                    d -> new Resource(d, this), Resource::getDelegate);
    }

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

    public void addResource(Resource resource) {
        update(getDelegate().withResources(
               Stream.concat(getDelegate().getResources().stream(), Stream.of(resource.getDelegate()))
                        .collect(Collectors.toList())));
        resource.childrenTracking = this::replace;
    }

    public void removeResource(Resource resource) {
        update(getDelegate().withResources(
               getDelegate().getResources().stream()
                        .filter(e -> !Objects.equals(e, resource))
                        .collect(Collectors.toList())));
        resource.childrenTracking = null;
    }

    @Nonnull
    public List getTestResources() {
        return new WrapperList(
                    () -> getDelegate().getTestResources(), l -> update(getDelegate().withTestResources(l)),
                    d -> new Resource(d, this), Resource::getDelegate);
    }

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

    public void addTestResource(Resource testResource) {
        update(getDelegate().withTestResources(
               Stream.concat(getDelegate().getTestResources().stream(), Stream.of(testResource.getDelegate()))
                        .collect(Collectors.toList())));
        testResource.childrenTracking = this::replace;
    }

    public void removeTestResource(Resource testResource) {
        update(getDelegate().withTestResources(
               getDelegate().getTestResources().stream()
                        .filter(e -> !Objects.equals(e, testResource))
                        .collect(Collectors.toList())));
        testResource.childrenTracking = null;
    }

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

    public void setDirectory(String directory) {
        if (!Objects.equals(directory, getDirectory())) {
            update(getDelegate().withDirectory(directory));
        }
    }

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

    public void setFinalName(String finalName) {
        if (!Objects.equals(finalName, getFinalName())) {
            update(getDelegate().withFinalName(finalName));
        }
    }

    @Nonnull
    public List getFilters() {
        return new WrapperList(() -> getDelegate().getFilters(), this::setFilters, s -> s, s -> s);
    }

    public void setFilters(List filters) {
        if (!Objects.equals(filters, getFilters())) {
            update(getDelegate().withFilters(filters));
        }
    }

    public void addFilter(String filter) {
        update(getDelegate().withFilters(
               Stream.concat(getDelegate().getFilters().stream(), Stream.of(filter))
                        .collect(Collectors.toList())));
    }

    public void removeFilter(String filter) {
        update(getDelegate().withFilters(
               getDelegate().getFilters().stream()
                        .filter(e -> !Objects.equals(e, filter))
                        .collect(Collectors.toList())));
    }

    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.BuildBase.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.BuildBase.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().getResources().contains(oldDelegate)) {
            List list = new ArrayList<>(getDelegate().getResources());
            list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.Resource) newDelegate : d);
            update(getDelegate().withResources(list));
            return true;
        }
        if (getDelegate().getTestResources().contains(oldDelegate)) {
            List list = new ArrayList<>(getDelegate().getTestResources());
            list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.Resource) newDelegate : d);
            update(getDelegate().withTestResources(list));
            return true;
        }
        return false;
    }

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

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


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