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

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

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

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

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

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

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

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

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

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

    public void setSystem(String system) {
        if (!Objects.equals(system, getSystem())) {
            update(getDelegate().withSystem(system));
        }
    }

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

    public void setUrl(String url) {
        if (!Objects.equals(url, getUrl())) {
            update(getDelegate().withUrl(url));
        }
    }

    @Nonnull
    public List getNotifiers() {
        return new WrapperList(
                    () -> getDelegate().getNotifiers(), l -> update(getDelegate().withNotifiers(l)),
                    d -> new Notifier(d, this), Notifier::getDelegate);
    }

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

    public void addNotifier(Notifier notifier) {
        update(getDelegate().withNotifiers(
               Stream.concat(getDelegate().getNotifiers().stream(), Stream.of(notifier.getDelegate()))
                        .collect(Collectors.toList())));
        notifier.childrenTracking = this::replace;
    }

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

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

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

}