aboutsummaryrefslogtreecommitdiffstats
path: root/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/ProcessResult.java
blob: dc49b806ee87a87166d84b0ed814fa2986f2e6d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.dockerapi;

import java.util.Objects;

public class ProcessResult {
    private final int exitStatus;
    private final String output;
    private final String errors;

    public ProcessResult(int exitStatus, String output, String errors) {
        this.exitStatus = exitStatus;
        this.output = output;
        this.errors = errors;
    }

    public boolean isSuccess() { return exitStatus == 0; }
    public int getExitStatus() { return exitStatus; }

    public String getOutput() { return output; }

    public String getErrors() { return errors; }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof ProcessResult)) return false;
        ProcessResult other = (ProcessResult) o;
        return Objects.equals(exitStatus, other.exitStatus)
                && Objects.equals(output, other.output)
                && Objects.equals(errors, other.errors);
    }

    @Override
    public int hashCode() {
        return Objects.hash(exitStatus, output, errors);
    }

    @Override
    public String toString() {
        return "ProcessResult {"
                + " exitStatus=" + exitStatus
                + " output=" + output
                + " errors=" + errors
                + " }";
    }
}