summaryrefslogtreecommitdiffstats
path: root/vespajlib/src/main/java/com/yahoo/tensor/impl/TensorAddressEmpty.java
blob: eb7e62e913bd04d249500b28ab7686b5eb4dee8c (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

package com.yahoo.tensor.impl;

import com.yahoo.tensor.TensorAddress;

/**
 * A zero-dimensional address.
 *
 * @author baldersheim
 */
final class TensorAddressEmpty extends TensorAddressAny {

    static TensorAddress empty = new TensorAddressEmpty();

    private TensorAddressEmpty() {}

    @Override public int size() { return 0; }

    @Override public long numericLabel(int i) { throw new IllegalArgumentException("Empty address with no labels"); }

    @Override
    public TensorAddress withLabel(int labelIndex, long label) {
        throw new IllegalArgumentException("No label " + labelIndex);
    }

    @Override
    public int hashCode() { return 0; }

    @Override
    public boolean equals(Object o) { return o instanceof TensorAddressEmpty; }

}