summaryrefslogtreecommitdiffstats
path: root/document/src/main/java/com/yahoo/document/select/OrderingSpecification.java
blob: 97908d3190f9d1d7bfc6c3b97a6d3d74bf5c922a (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.document.select;

public class OrderingSpecification {
    public static int ASCENDING = 0;
    public static int DESCENDING = 1;

    public final int order;
    public final long orderingStart;
    public final short widthBits;
    public final short divisionBits;

    public OrderingSpecification() {
        this(ASCENDING, (long)0, (short)0, (short)0);
    }

    public OrderingSpecification(int order) {
        this(order, (long)0, (short)0, (short)0);
    }

    public OrderingSpecification(int order, long orderingStart, short widthBits, short divisionBits) {
        this.order = order;
        this.orderingStart = orderingStart;
        this.widthBits = widthBits;
        this.divisionBits = divisionBits;
    }

    public int getOrder() { return order; }
    public long getOrderingStart() { return orderingStart; }
    public short getWidthBits() { return widthBits; }
    public short getDivisionBits() { return divisionBits; }

    @Override
    public boolean equals(Object other) {
        OrderingSpecification o = (OrderingSpecification)other;
        if (o == null) return false;

        return (order == o.order && orderingStart == o.orderingStart && widthBits == o.widthBits && divisionBits == o.divisionBits);
    }

    @Override
    public int hashCode() {
        return java.util.Objects.hash(order, orderingStart, widthBits, divisionBits);
    }

    public String toString() {
        return "O: " + order + " S:" + orderingStart + " W:" + widthBits + " D:" + divisionBits;
    }
}