aboutsummaryrefslogtreecommitdiffstats
path: root/vespaclient-java/src/main/java/com/yahoo/vespastat/ClientParameters.java
blob: 54d70ccc8c95b51ef86f37333ca292679fc9adec (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespastat;

import com.yahoo.document.FixedBucketSpaces;

/**
 * This class contains the program parameters.
 *
 * @author bjorncs
 */
public class ClientParameters {
    // Show help page if true
    public final boolean help;
    // Dump list of documents for all buckets matching the selection if true
    public final boolean dumpData;
    // The message bus route
    public final String route;
    // The selection type
    public final SelectionType selectionType;
    // The selection id
    public final String id;
    public final String bucketSpace;

    public ClientParameters(
            boolean help,
            boolean dumpData,
            String route,
            SelectionType selectionType,
            String id) {
        this(help, dumpData, route, selectionType, id, FixedBucketSpaces.defaultSpace());
    }

    public ClientParameters(
            boolean help,
            boolean dumpData,
            String route,
            SelectionType selectionType,
            String id,
            String bucketSpace) {
        this.help = help;
        this.dumpData = dumpData;
        this.route = route;
        this.selectionType = selectionType;
        this.id = id;
        this.bucketSpace = bucketSpace;
    }

    public enum SelectionType {USER, GROUP, BUCKET, GID, DOCUMENT}

    public static class Builder {
        private boolean help;
        private boolean dumpData;
        private String route;
        private SelectionType selectionType;
        private String id;
        private String bucketSpace = FixedBucketSpaces.defaultSpace();

        public Builder setHelp(boolean help) {
            this.help = help;
            return this;
        }

        public Builder setDumpData(boolean dumpData) {
            this.dumpData = dumpData;
            return this;
        }

        public Builder setRoute(String route) {
            this.route = route;
            return this;
        }

        public Builder setSelectionType(SelectionType selectionType) {
            this.selectionType = selectionType;
            return this;
        }

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

        public Builder setBucketSpace(String bucketSpace) {
            this.bucketSpace = bucketSpace;
            return this;
        }

        public ClientParameters build() {
            return new ClientParameters(help, dumpData, route, selectionType, id, bucketSpace);
        }
    }

}