aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/grouping/result/BucketGroupId.java
blob: a56b75e3a91d705fdc486b14c4b31bc2011782ff (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.result;

/**
 * This abstract class is used in {@link Group} instances where the identifying expression evaluated to a {@link
 * com.yahoo.search.grouping.request.BucketValue}. The range is inclusive-from and exclusive-to.
 *
 * @author Simon Thoresen Hult
 */
public abstract class BucketGroupId<T> extends GroupId {

    private final T from;
    private final T to;

    /**
     * Constructs a new instance of this class.
     *
     * @param type The type of this id's value.
     * @param from The inclusive-from of the range.
     * @param to   The exclusive-to of the range.
     */
    public BucketGroupId(String type, T from, T to) {
        this(type, from, String.valueOf(from), to, String.valueOf(to));
    }

    /**
     * Constructs a new instance of this class.
     *
     * @param type      The type of this id's value.
     * @param from      The inclusive-from of the range.
     * @param fromImage The String representation of the <code>from</code> argument.
     * @param to        The exclusive-to of the range.
     * @param toImage   The String representation of the <code>to</code> argument.
     */
    public BucketGroupId(String type, T from, String fromImage, T to, String toImage) {
        super(type, fromImage, toImage);
        this.from = from;
        this.to = to;
    }

    /**
     * Returns the inclusive-from of the value range.
     *
     * @return The from-value.
     */
    public T getFrom() {
        return from;
    }

    /**
     * Returns the exclusive-to of the value range.
     *
     * @return The to-value.
     */
    public T getTo() {
        return to;
    }

}