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

com.squidex.api.resources.contents.requests.ContentsPostContentRequest Maven / Gradle / Ivy

package com.squidex.api.resources.contents.requests;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonDeserialize(builder = ContentsPostContentRequest.Builder.class)
public final class ContentsPostContentRequest {
    private final Optional unpublished;

    private final Optional languages;

    private final Optional status;

    private final Optional id;

    private final Optional publish;

    private final Map> body;

    private ContentsPostContentRequest(
            Optional unpublished,
            Optional languages,
            Optional status,
            Optional id,
            Optional publish,
            Map> body) {
        this.unpublished = unpublished;
        this.languages = languages;
        this.status = status;
        this.id = id;
        this.publish = publish;
        this.body = body;
    }

    /**
     * @return Return unpublished content items.
     */
    @JsonProperty("X-Unpublished")
    public Optional getUnpublished() {
        return unpublished;
    }

    /**
     * @return Only resolve these languages (comma-separated).
     */
    @JsonProperty("X-Languages")
    public Optional getLanguages() {
        return languages;
    }

    /**
     * @return The initial status.
     */
    @JsonProperty("status")
    public Optional getStatus() {
        return status;
    }

    /**
     * @return The optional custom content id.
     */
    @JsonProperty("id")
    public Optional getId() {
        return id;
    }

    /**
     * @return True to automatically publish the content.
     */
    @JsonProperty("publish")
    public Optional getPublish() {
        return publish;
    }

    @JsonProperty("body")
    public Map> getBody() {
        return body;
    }

    @Override
    public boolean equals(Object other) {
        if (this == other) return true;
        return other instanceof ContentsPostContentRequest && equalTo((ContentsPostContentRequest) other);
    }

    private boolean equalTo(ContentsPostContentRequest other) {
        return unpublished.equals(other.unpublished)
                && languages.equals(other.languages)
                && status.equals(other.status)
                && id.equals(other.id)
                && publish.equals(other.publish)
                && body.equals(other.body);
    }

    @Override
    public int hashCode() {
        return Objects.hash(this.unpublished, this.languages, this.status, this.id, this.publish, this.body);
    }

    @Override
    public String toString() {
        return "ContentsPostContentRequest{" + "unpublished: " + unpublished + ", languages: " + languages
                + ", status: " + status + ", id: " + id + ", publish: " + publish + ", body: " + body + "}";
    }

    public static Builder builder() {
        return new Builder();
    }

    @JsonIgnoreProperties(ignoreUnknown = true)
    public static final class Builder {
        private Optional unpublished = Optional.empty();

        private Optional languages = Optional.empty();

        private Optional status = Optional.empty();

        private Optional id = Optional.empty();

        private Optional publish = Optional.empty();

        private Map> body = new LinkedHashMap<>();

        private Builder() {}

        public Builder from(ContentsPostContentRequest other) {
            unpublished(other.getUnpublished());
            languages(other.getLanguages());
            status(other.getStatus());
            id(other.getId());
            publish(other.getPublish());
            body(other.getBody());
            return this;
        }

        @JsonSetter(value = "X-Unpublished", nulls = Nulls.SKIP)
        public Builder unpublished(Optional unpublished) {
            this.unpublished = unpublished;
            return this;
        }

        public Builder unpublished(Boolean unpublished) {
            this.unpublished = Optional.of(unpublished);
            return this;
        }

        @JsonSetter(value = "X-Languages", nulls = Nulls.SKIP)
        public Builder languages(Optional languages) {
            this.languages = languages;
            return this;
        }

        public Builder languages(String languages) {
            this.languages = Optional.of(languages);
            return this;
        }

        @JsonSetter(value = "status", nulls = Nulls.SKIP)
        public Builder status(Optional status) {
            this.status = status;
            return this;
        }

        public Builder status(String status) {
            this.status = Optional.of(status);
            return this;
        }

        @JsonSetter(value = "id", nulls = Nulls.SKIP)
        public Builder id(Optional id) {
            this.id = id;
            return this;
        }

        public Builder id(String id) {
            this.id = Optional.of(id);
            return this;
        }

        @JsonSetter(value = "publish", nulls = Nulls.SKIP)
        public Builder publish(Optional publish) {
            this.publish = publish;
            return this;
        }

        public Builder publish(Boolean publish) {
            this.publish = Optional.of(publish);
            return this;
        }

        @JsonSetter(value = "body", nulls = Nulls.SKIP)
        public Builder body(Map> body) {
            this.body.clear();
            this.body.putAll(body);
            return this;
        }

        public Builder putAllBody(Map> body) {
            this.body.putAll(body);
            return this;
        }

        public Builder body(String key, Map value) {
            this.body.put(key, value);
            return this;
        }

        public ContentsPostContentRequest build() {
            return new ContentsPostContentRequest(unpublished, languages, status, id, publish, body);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy