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

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

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

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

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

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

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

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

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

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

    public void setIncludes(List includes) {
        if (!Objects.equals(includes, getIncludes())) {
            update(getDelegate().withIncludes(includes));
        }
    }

    public void addInclude(String include) {
        update(getDelegate().withIncludes(
               Stream.concat(getDelegate().getIncludes().stream(), Stream.of(include))
                        .collect(Collectors.toList())));
    }

    public void removeInclude(String include) {
        update(getDelegate().withIncludes(
               getDelegate().getIncludes().stream()
                        .filter(e -> !Objects.equals(e, include))
                        .collect(Collectors.toList())));
    }

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

    public void setExcludes(List excludes) {
        if (!Objects.equals(excludes, getExcludes())) {
            update(getDelegate().withExcludes(excludes));
        }
    }

    public void addExclude(String exclude) {
        update(getDelegate().withExcludes(
               Stream.concat(getDelegate().getExcludes().stream(), Stream.of(exclude))
                        .collect(Collectors.toList())));
    }

    public void removeExclude(String exclude) {
        update(getDelegate().withExcludes(
               getDelegate().getExcludes().stream()
                        .filter(e -> !Objects.equals(e, exclude))
                        .collect(Collectors.toList())));
    }

    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.PatternSet.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.PatternSet.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 patternSetToApiV4(List list) {
        return list != null ? new WrapperList<>(list, PatternSet::getDelegate, PatternSet::new) : null;
    }

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


            
    /**
     * @see java.lang.Object#toString()
     */
    public String toString() {
        return "PatternSet [" +
            "includes: {" + getIncludes().stream().collect(java.util.stream.Collectors.joining(", ")) + "}, " +
            "excludes: {" + getExcludes().stream().collect(java.util.stream.Collectors.joining(", ")) + "}]";
    }
            
          
}