Exclude.java

package info.textgrid.services.textapi;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.ArrayList;
import java.util.List;

/**
 * Represents an exclusion rule from the "exclude" section of a field override
 * configuration. Entries whose ID matches "from" have the IDs listed under
 * "target" removed from their list (collections, manifests or items).
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Exclude {

    /**
     * The ID of the resource whose list should be filtered.
     * The alias "form" is accepted for backward compatibility with
     * existing configuration files.
     */
    @JsonAlias("form")
    private String from;

    /**
     * List of IDs to remove from the resource's list.
     */
    private List<String> target;

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    public List<String> getTarget() {
        return target;
    }

    public void setTarget(List<String> target) {
        this.target = target;
    }

    public void addTarget(String target) {
        if (this.target == null) {
            this.target = new ArrayList<>();
        }
        this.target.add(target);
    }
}