summaryrefslogtreecommitdiffstats
path: root/vespajlib/src/main/java/com/yahoo/tensor/impl/TensorAddressEmpty.java
blob: 2d9cd3eed789d3c6f1ceb806d544e15dfb86bc47 (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
// 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;

/**
 * 0 dimesional/empty 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; }
}