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

org.apache.maven.model.Activation 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.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 Activation
    extends BaseObject
{

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

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

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

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

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

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

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

    public boolean isActiveByDefault() {
        return getDelegate().isActiveByDefault();
    }

    public void setActiveByDefault(boolean activeByDefault) {
        if (!Objects.equals(activeByDefault, isActiveByDefault())) {
            update(getDelegate().withActiveByDefault(activeByDefault));
        }
    }

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

    public void setJdk(String jdk) {
        if (!Objects.equals(jdk, getJdk())) {
            update(getDelegate().withJdk(jdk));
        }
    }

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

    public void setOs(ActivationOS os) {
        if (!Objects.equals(os, getOs())){
            if (os != null) {
                update(getDelegate().withOs(os.getDelegate()));
                os.childrenTracking = this::replace;
            } else {
                update(getDelegate().withOs(null));
            }
        }
    }

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

    public void setProperty(ActivationProperty property) {
        if (!Objects.equals(property, getProperty())){
            if (property != null) {
                update(getDelegate().withProperty(property.getDelegate()));
                property.childrenTracking = this::replace;
            } else {
                update(getDelegate().withProperty(null));
            }
        }
    }

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

    public void setFile(ActivationFile file) {
        if (!Objects.equals(file, getFile())){
            if (file != null) {
                update(getDelegate().withFile(file.getDelegate()));
                file.childrenTracking = this::replace;
            } else {
                update(getDelegate().withFile(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.Activation.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.Activation.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().getOs()) {
            update(getDelegate().withOs((org.apache.maven.api.model.ActivationOS) newDelegate));
            return true;
        }
        if (oldDelegate == getDelegate().getProperty()) {
            update(getDelegate().withProperty((org.apache.maven.api.model.ActivationProperty) newDelegate));
            return true;
        }
        if (oldDelegate == getDelegate().getFile()) {
            update(getDelegate().withFile((org.apache.maven.api.model.ActivationFile) newDelegate));
            return true;
        }
        return false;
    }

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

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

}