summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/grouping/request/Infinite.java
blob: dfee7d0e48a92265cbb9262bab9eed598356b659 (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
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.request;

/**
 * This class represents an Infinite value that may be used as a bucket
 * size specifier.
 *
 * @author <a href="mailto:lulf@yahoo-inc.com">Ulf Lilleengen</a>
 */
@SuppressWarnings("rawtypes")
public class Infinite implements Comparable {
    private final boolean negative;

    /**
     * Create an Infinite object with positive or negative sign.
     * @param negative the signedness.
     */
    public Infinite(boolean negative) {
        this.negative = negative;
    }

    /**
     * Override the toString method in order to be re-parseable.
     */
    @Override
    public String toString() {
        return (negative ? "-inf" : "inf");
    }

    /**
     * An infinity value is always less than or greater than.
     */
    @Override
    public int compareTo(Object rhs) {
        return (negative ? -1 : 1);
    }
}