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

org.apache.maven.model.Contributor 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;

@Generated
public class Contributor
    extends BaseObject
{

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

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

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

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

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

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

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

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

    public void setName(String name) {
        if (!Objects.equals(name, getName())) {
            update(getDelegate().withName(name));
        }
    }

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

    public void setEmail(String email) {
        if (!Objects.equals(email, getEmail())) {
            update(getDelegate().withEmail(email));
        }
    }

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

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

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

    public void setOrganization(String organization) {
        if (!Objects.equals(organization, getOrganization())) {
            update(getDelegate().withOrganization(organization));
        }
    }

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

    public void setOrganizationUrl(String organizationUrl) {
        if (!Objects.equals(organizationUrl, getOrganizationUrl())) {
            update(getDelegate().withOrganizationUrl(organizationUrl));
        }
    }

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

    public void setRoles(List roles) {
        if (!Objects.equals(roles, getRoles())) {
            update(getDelegate().withRoles(roles));
        }
    }

    public void addRole(String role) {
        update(getDelegate().withRoles(
               Stream.concat(getDelegate().getRoles().stream(), Stream.of(role))
                        .collect(Collectors.toList())));
    }

    public void removeRole(String role) {
        update(getDelegate().withRoles(
               getDelegate().getRoles().stream()
                        .filter(e -> !Objects.equals(e, role))
                        .collect(Collectors.toList())));
    }

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

    public void setTimezone(String timezone) {
        if (!Objects.equals(timezone, getTimezone())) {
            update(getDelegate().withTimezone(timezone));
        }
    }

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

    public void setProperties(Properties properties) {
        Map map = properties.entrySet().stream()
                .collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString()));
        if (!Objects.equals(map, getDelegate().getProperties())) {
            update(getDelegate().withProperties(map));
        }
    }

    public void addProperty(String key, String value) {
        getProperties().put(key, value);
    }

    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.Contributor.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.Contributor.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;
        }
        return false;
    }

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

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


            
    /**
     * @see java.lang.Object#toString()
     */
    public String toString()
    {
        return "Contributor {name=" + getName() + ", email=" + getEmail() + "}";
    }
            
          
}