Collection.java

package info.textgrid.services.textapi.apiv2;

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

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

/**
 * TextAPI v2 Collection model.
 * Represents a curated list of texts or other collections.
 */
@JsonPropertyOrder({
    "@context",
    "textapiVersion",
    "id",
    "textapiType",
    "revision",
    "created",
    "modified",
    "titles",
    "collectors",
    "editors",
    "funders",
    "description",
    "total",
    "manifests",
    "collections",
    "partOf",
    "prevRevision",
    "annotationCollection"
})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Collection {

    @JsonProperty("@context")
    private String context;

    private String textapiVersion;

    private String id;

    @JsonProperty("textapiType")
    private String textapiType;

    private String revision;

    private String created;

    private String modified;

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<String> titles = new ArrayList<>();

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<Agent> collectors = new ArrayList<>();

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<Agent> editors;

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<Agent> funders;

    private String description;

    private Integer total;

    @JsonTypeInfo(use = JsonTypeInfo.Id.NONE, include = JsonTypeInfo.As.WRAPPER_OBJECT)
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<Object> manifests;

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<CollectionReference> collections;

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<String> partOf;

    private String prevRevision;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String annotationCollection;

    /**
     * Required JSON-LD context
     */
    public String getContext() {
        return context;
    }

    public Collection setContext(String context) {
        this.context = context;
        return this;
    }

    /**
     * Required TextAPI version (must be 2.0.0)
     */
    public String getTextapiVersion() {
        return textapiVersion;
    }

    public Collection setTextapiVersion(String textapiVersion) {
        this.textapiVersion = textapiVersion;
        return this;
    }

    /**
     * Required collection IRI
     */
    public String getId() {
        return id;
    }

    public Collection setId(String id) {
        this.id = id;
        return this;
    }

    /**
     * Required type (must be "TextApiCollection")
     */
    public String getTextapiType() {
        return textapiType;
    }

    public Collection setTextapiType(String textapiType) {
        this.textapiType = textapiType;
        return this;
    }

    /**
     * Required revision identifier
     */
    public String getRevision() {
        return revision;
    }

    public Collection setRevision(String revision) {
        this.revision = revision;
        return this;
    }

    /**
     * Required creation timestamp
     */
    public String getCreated() {
        return created;
    }

    public Collection setCreated(String created) {
        this.created = created;
        return this;
    }

    /**
     * Required modification timestamp
     */
    public String getModified() {
        return modified;
    }

    public Collection setModified(String modified) {
        this.modified = modified;
        return this;
    }

    /**
     * Required titles (at least one)
     */
    public List<String> getTitles() {
        return titles;
    }

    public Collection setTitles(List<String> titles) {
        this.titles = titles;
        return this;
    }

    public Collection addTitle(String title) {
        this.titles.add(title);
        return this;
    }

    /**
     * Required collectors (at least one agent)
     */
    public List<Agent> getCollectors() {
        return collectors;
    }

    public Collection setCollectors(List<Agent> collectors) {
        this.collectors = collectors;
        return this;
    }

    public Collection addCollector(Agent collector) {
        this.collectors.add(collector);
        return this;
    }

    /**
     * Optional editors
     */
    public List<Agent> getEditors() {
        return editors;
    }

    public Collection setEditors(List<Agent> editors) {
        this.editors = editors;
        return this;
    }

    public Collection addEditor(Agent editor) {
        if (this.editors == null) {
            this.editors = new ArrayList<>();
        }
        this.editors.add(editor);
        return this;
    }

    /**
     * Optional funders
     */
    public List<Agent> getFunders() {
        return funders;
    }

    public Collection setFunders(List<Agent> funders) {
        this.funders = funders;
        return this;
    }

    public Collection addFunder(Agent funder) {
        if (this.funders == null) {
            this.funders = new ArrayList<>();
        }
        this.funders.add(funder);
        return this;
    }

    /**
     * Optional collection description
     */
    public String getDescription() {
        return description;
    }

    public Collection setDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * Required total count of manifests or sub-collections
     */
    public Integer getTotal() {
        return total;
    }

    public Collection setTotal(Integer total) {
        this.total = total;
        return this;
    }

    /**
     * Optional list of manifest references or full manifests
     * If set, collections must be null
     */
    public List<Object> getManifests() {
        return manifests;
    }

    public Collection setManifests(List<Object> manifests) {
        this.manifests = manifests;
        return this;
    }

    public Collection addManifest(Object manifest) {
        if (this.manifests == null) {
            this.manifests = new ArrayList<>();
        }
        this.manifests.add(manifest);
        return this;
    }

    /**
     * Optional list of sub-collection references (id + shortTitle)
     * If set, manifests must be null
     */
    public List<CollectionReference> getCollections() {
        return collections;
    }

    public Collection setCollections(List<CollectionReference> collections) {
        this.collections = collections;
        return this;
    }

    public Collection addCollection(CollectionReference collection) {
        if (this.collections == null) {
            this.collections = new ArrayList<>();
        }
        this.collections.add(collection);
        return this;
    }

    /**
     * Optional parent collections
     */
    public List<String> getPartOf() {
        return partOf;
    }

    public Collection setPartOf(List<String> partOf) {
        this.partOf = partOf;
        return this;
    }

    public Collection addPartOf(String partOf) {
        if (this.partOf == null) {
            this.partOf = new ArrayList<>();
        }
        this.partOf.add(partOf);
        return this;
    }

    /**
     * Optional previous revision
     */
    public String getPrevRevision() {
        return prevRevision;
    }

    public Collection setPrevRevision(String prevRevision) {
        this.prevRevision = prevRevision;
        return this;
    }

    /**
     * Optional annotations collection URL
     */
    public String getAnnotationCollection() {
        return annotationCollection;
    }

    public Collection setAnnotationCollection(String annotationCollection) {
        this.annotationCollection = annotationCollection;
        return this;
    }
}