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

org.apache.maven.toolchain.model.ToolchainModel Maven / Gradle / Ivy

There is a newer version: 4.0.0-beta-5
Show 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.toolchain.model;

import java.io.Serializable;
import java.util.AbstractList;
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 ToolchainModel
    extends TrackableBase
    implements Serializable, Cloneable
{

    public ToolchainModel() {
        this(org.apache.maven.api.toolchain.ToolchainModel.newInstance());
    }

    public ToolchainModel(org.apache.maven.api.toolchain.ToolchainModel delegate) {
        this(delegate, null);
    }

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

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

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

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

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

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

    public void setType(String type) {
        if (!Objects.equals(type, getType())) {
            update(getDelegate().withType(type));
        }
    }

    @Nonnull
    public Properties getProvides() {
        return new WrapperProperties(() -> getDelegate().getProvides(), this::setProvides);
    }

    public void setProvides(Properties provides) {
        Map map = provides.entrySet().stream()
                .collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString()));
        if (!Objects.equals(map, getDelegate().getProvides())) {
            update(getDelegate().withProvides(map));
        }
    }

    public void addProvide(String key, String value) {
        getProvides().put(key, value);
    }

    public Object getConfiguration() {
        return getDelegate().getConfiguration() != null ? new Xpp3Dom(getDelegate().getConfiguration(), this::replace) : null;
    }

    public void setConfiguration(Object configuration) {
        if (configuration instanceof Xpp3Dom) {
            if (!Objects.equals(((Xpp3Dom) configuration).getDom(), getDelegate().getConfiguration())) {
                update(getDelegate().withConfiguration(((Xpp3Dom) configuration).getDom()));
                ((Xpp3Dom) configuration).setChildrenTracking(this::replace);
            }
        } else if (configuration == null) {
            if (getDelegate().getConfiguration() != null) {
                update(getDelegate().withConfiguration(null));
            }
        } else {
            throw new IllegalArgumentException("Expected an Xpp3Dom object but received a " + configuration.getClass() + ": " + configuration);
        }
    }

    protected boolean replace(Object oldDelegate, Object newDelegate) {
        if (super.replace(oldDelegate, newDelegate)) {
            return true;
        }
        if (getDelegate().getConfiguration() == oldDelegate) {
            update(getDelegate().withConfiguration((org.apache.maven.api.xml.XmlNode) newDelegate));
        }
        return false;
    }

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

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy