aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/couscous/interpreter/values/FieldValue.java
blob: 90a6099af6d5806960188bf06f89bb3c972f1036 (plain)
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
package org.zwobble.couscous.interpreter.values;

import org.zwobble.couscous.ast.TypeName;

public final class FieldValue {
    private final boolean isStatic;
    private final String name;
    private final TypeName type;

    public FieldValue(final boolean isStatic, final String name, final TypeName type) {
        this.isStatic = isStatic;
        this.name = name;
        this.type = type;
    }

    public boolean isStatic() {
        return isStatic;
    }

    public String getName() {
        return this.name;
    }

    public TypeName getType() {
        return this.type;
    }

    @Override
    public String toString() {
        return "FieldValue(" +
            "isStatic=" + isStatic +
            ", name='" + name + '\'' +
            ", type=" + type +
            ')';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        FieldValue that = (FieldValue) o;

        if (isStatic != that.isStatic) return false;
        if (!name.equals(that.name)) return false;
        return type.equals(that.type);

    }

    @Override
    public int hashCode() {
        int result = (isStatic ? 1 : 0);
        result = 31 * result + name.hashCode();
        result = 31 * result + type.hashCode();
        return result;
    }
}