aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-feed-client/src/main/java/ai/vespa/feed/client/Result.java
blob: 5ff3fd0a219d0ee4422205a2cfb7cee1192a710b (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 Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.feed.client;

import java.util.Optional;

/**
 * Result for a document operation which completed normally.
 *
 * @author bjorncs
 * @author jonmv
 */
public class Result {

    private final Type type;
    private final DocumentId documentId;
    private final String resultMessage;
    private final String traceMessage;

    Result(Type type, DocumentId documentId, String resultMessage, String traceMessage) {
        this.type = type;
        this.documentId = documentId;
        this.resultMessage = resultMessage;
        this.traceMessage = traceMessage;
    }

    public enum Type {
        success,
        conditionNotMet
    }

    public Type type() { return type; }
    public DocumentId documentId() { return documentId; }
    public Optional<String> resultMessage() { return Optional.ofNullable(resultMessage); }
    public Optional<String> traceMessage() { return Optional.ofNullable(traceMessage); }

    @Override
    public String toString() {
        return "Result{" +
               "type=" + type +
               ", documentId=" + documentId +
               ", resultMessage='" + resultMessage + '\'' +
               ", traceMessage='" + traceMessage + '\'' +
               '}';
    }

}