aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/couscous/values/IntegerValue.java
blob: ed0040ab0486f820c4a7cb2a60d8ebd30877516d (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
package org.zwobble.couscous.values;

import org.zwobble.couscous.ast.TypeName;

public final class IntegerValue implements PrimitiveValue {
    public static final TypeName REF = TypeName.of("int");
    private final int value;
    
    @Override
    public <T> T accept(PrimitiveValueVisitor<T> visitor) {
        return visitor.visitInteger(value);
    }
    
    @Override
    public TypeName getType() {
        return REF;
    }
    
    public IntegerValue(final int value) {
        this.value = value;
    }
    
    public int getValue() {
        return this.value;
    }
    
    @java.lang.Override
    public boolean equals(final java.lang.Object o) {
        if (o == this) return true;
        if (!(o instanceof IntegerValue)) return false;
        final IntegerValue other = (IntegerValue)o;
        if (this.getValue() != other.getValue()) return false;
        return true;
    }
    
    @java.lang.Override
    public int hashCode() {
        final int PRIME = 59;
        int result = 1;
        result = result * PRIME + this.getValue();
        return result;
    }
    
    @java.lang.Override
    public java.lang.String toString() {
        return "IntegerValue(value=" + this.getValue() + ")";
    }
}