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

io.github.pmckeown.dependencytrack.Response Maven / Gradle / Ivy

Go to download

Maven plugin to integrate with a Dependency Track server to submit dependency manifests and gather project metrics.

There is a newer version: 1.7.0
Show newest version
package io.github.pmckeown.dependencytrack;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Optional;

/**
 * Wrapper for API responses from the Dependency Track server
 *
 * @author Paul McKeown
 */
public class Response {

    private final int status;
    private final String statusText;
    private boolean success;
    private final Optional body;

    public Response(int status, String statusText, boolean success) {
        this.status = status;
        this.statusText = statusText;
        this.success = success;
        this.body = Optional.empty();
    }

    public Response(int status, String statusText, boolean success, Optional body) {
        this.status = status;
        this.statusText = statusText;
        this.success = success;
        this.body = body;
    }

    public int getStatus() {
        return this.status;
    }

    public String getStatusText() {
        return this.statusText;
    }

    public boolean isSuccess() {
        return this.success;
    }

    public Optional getBody() {
        return this.body;
    }

    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    }
}