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

import static java.util.Arrays.asList;

import lombok.Value;
import lombok.val;

@Value
public class IntegerValue implements InterpreterValue {
    public static final ConcreteType<?> TYPE = ConcreteType.<IntegerValue>builder("Integer")
        .staticMethod("parseInt", () -> asList(StringValue.TYPE),
            arguments -> {
                val value = (StringValue)arguments.get(0);
                return new IntegerValue(Integer.parseInt(value.getValue()));
            })
        
        .build();
    
    int value;

    @Override
    public ConcreteType<?> getType() {
        return TYPE;
    }
}