aboutsummaryrefslogtreecommitdiffstats
path: root/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/GetBucketListReply.java
blob: 3812769311adf3ccac158e5833101f8b8557435b (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.documentapi.messagebus.protocol;

import com.yahoo.document.BucketId;

import java.util.ArrayList;
import java.util.List;

public class GetBucketListReply extends DocumentReply {

    public static class BucketInfo {
        BucketId bucket;
        String bucketInformation;

        BucketInfo() {
            // must be deserialized into
        }

        public BucketInfo(BucketId bucket, String bucketInformation) {
            this.bucket = bucket;
            this.bucketInformation = bucketInformation;
        }

        public BucketId getBucketId() {
            return bucket;
        }

        public String getBucketInformation() {
            return bucketInformation;
        }

        @Override
        public boolean equals(Object obj) {
            if (!(obj instanceof BucketInfo)) {
                return false;
            }
            BucketInfo rhs = (BucketInfo)obj;
            if (bucket == null) {
                if (rhs.bucket != null) {
                    return false;
                }
            } else if (!bucket.equals(rhs.bucket)) {
                return false;
            }
            if (bucketInformation == null) {
                if (rhs.bucketInformation != null) {
                    return false;
                }
            } else if (!bucketInformation.equals(rhs.bucketInformation)) {
                return false;
            }
            return true;
        }

        @Override
        public int hashCode() {
            return java.util.Objects.hash(bucket, bucketInformation);
        }

        @Override
        public String toString() {
            return String.format("BucketInfo(%s: %s)", bucket, bucketInformation);
        }
    }

    private final List<BucketInfo> buckets = new ArrayList<BucketInfo>();

    public GetBucketListReply() {
        super(DocumentProtocol.REPLY_GETBUCKETLIST);
    }

    public List<BucketInfo> getBuckets() {
        return buckets;
    }
}