aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/schema/derived/NativeTable.java
blob: 6eff2487bca4b5828ae2c68a8e1a297821658f09 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.derived;

/**
 * A named rank table of a certain type.
 *
 * @author geirst
 */
public class NativeTable {

    private String name;

    private Type type;

    /** A table type enumeration */
    public static class Type {

        public static Type FIRST_OCCURRENCE = new Type("firstOccurrenceTable");
        public static Type OCCURRENCE_COUNT = new Type("occurrenceCountTable");
        public static Type WEIGHT = new Type("weightTable");
        public static Type PROXIMITY = new Type("proximityTable");
        public static Type REVERSE_PROXIMITY = new Type("reverseProximityTable");

        private String name;

        private Type(String name) {
            this.name = name;
        }

        public String getName() { return name; }

        public boolean equals(Object object) {
            if (!(object instanceof Type)) {
                return false;
            }
            Type other = (Type)object;
            return this.name.equals(other.name);
        }

        public int hashCode() {
            return name.hashCode();
        }

        public String toString() {
            return getName();
        }
    }

    public NativeTable(Type type, String name) {
        this.type = type;
        this.name = name;
    }

    public Type getType() { return type; }

    public String getName() { return name; }

    public int hashCode() {
        return type.hashCode() + 17*name.hashCode();
    }

    public boolean equals(Object object) {
        if (! (object instanceof NativeTable)) return false;
        NativeTable other = (NativeTable)object;
        return other.getName().equals(this.getName()) && other.getType().equals(this.getType());
    }

    public String toString() {
        return getType() + ": " + getName();
    }

}