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

import java.util.Objects;

import static java.util.Objects.requireNonNullElse;

/*
 * Abstract class representing an IN operator.
 *
 * @author toregge
 */
public abstract class InItem extends Item {
    private String indexName;
    public InItem(String indexName) {
        this.indexName = requireNonNullElse(indexName, "");
    }

    @Override
    public void setIndexName(String index) {
        this.indexName = requireNonNullElse(index, "");
    }
    public String getIndexName() {
        return indexName;
    }

    @Override
    public String getName() {
        return getItemType().name();
    }

    @Override
    public boolean equals(Object o) {
        if (o == this) return true;
        if ( ! super.equals(o)) return false;
        var other = (InItem)o;
        if ( ! Objects.equals(this.indexName, other.indexName)) return false;
        return true;
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), indexName);
    }

};