package dst.ass3.elastic;

import dst.ass3.messaging.RequestType;

import java.util.Objects;

/**
 * Value type that represents a container.
 */
public class ContainerInfo {

    /**
     * The name of the container image.
     */
    private String image;

    /**
     * The container ID.
     */
    private String containerId;

    /**
     * True if the container is running.
     */
    private boolean running;

    /**
     * If the container is a worker (indicated by the image dst/ass3-worker), then this field should contain the worker
     * type. Otherwise it can be null.
     */
    private RequestType workerType;

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getContainerId() {
        return containerId;
    }

    public void setContainerId(String containerId) {
        this.containerId = containerId;
    }

    public boolean isRunning() {
        return running;
    }

    public void setRunning(boolean running) {
        this.running = running;
    }


    public RequestType getWorkerType() {
        return workerType;
    }

    public void setWorkerType(RequestType workerType) {
        this.workerType = workerType;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ContainerInfo that = (ContainerInfo) o;
        return running == that.running &&
                Objects.equals(image, that.image) &&
                Objects.equals(containerId, that.containerId) &&
                Objects.equals(workerType, that.workerType);
    }

    @Override
    public int hashCode() {

        return Objects.hash(image, containerId, running, workerType);
    }

    @Override
    public String toString() {
        return "ContainerInfo{" +
                "image='" + image + '\'' +
                ", containerId='" + containerId + '\'' +
                ", running=" + running +
                ", workerType='" + workerType + '\'' +
                '}';
    }
}
