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

org.apache.maven.model.Profile 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.Properties;
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;
import org.codehaus.plexus.util.xml.Xpp3Dom;

@Generated
public class Profile
    extends ModelBase
    implements Serializable, Cloneable
{

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

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

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

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

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

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

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

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

    public void setId(String id) {
        if (!Objects.equals(id, getId())) {
            update(getDelegate().withId(id));
        }
    }

    public Activation getActivation() {
        return getDelegate().getActivation() != null ? new Activation(getDelegate().getActivation(), this) : null;
    }

    public void setActivation(Activation activation) {
        if (!Objects.equals(activation, getActivation())){
            if (activation != null) {
                update(getDelegate().withActivation(activation.getDelegate()));
                activation.childrenTracking = this::replace;
            } else {
                update(getDelegate().withActivation(null));
            }
        }
    }

    public BuildBase getBuild() {
        return getDelegate().getBuild() != null ? new BuildBase(getDelegate().getBuild(), this) : null;
    }

    public void setBuild(BuildBase build) {
        if (!Objects.equals(build, getBuild())){
            if (build != null) {
                update(getDelegate().withBuild(build.getDelegate()));
                build.childrenTracking = this::replace;
            } else {
                update(getDelegate().withBuild(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.Profile.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.Profile.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 (oldDelegate == getDelegate().getActivation()) {
            update(getDelegate().withActivation((org.apache.maven.api.model.Activation) newDelegate));
            return true;
        }
        if (oldDelegate == getDelegate().getBuild()) {
            update(getDelegate().withBuild((org.apache.maven.api.model.BuildBase) newDelegate));
            return true;
        }
        return false;
    }

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

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


            
    public static final String SOURCE_POM = "pom";

    public static final String SOURCE_SETTINGS = "settings.xml";

    public void setSource(String source) {
        getDelegate().setSource(source);
    }

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

    /**
     * @see java.lang.Object#toString()
     */
    public String toString() {
        return "Profile {id: " + getId() + ", source: " + getSource() + "}";
    }
            
          
}