

package io.crate.types;

import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;

import java.io.IOException;

public final class IntegerLiteralTypeSignature extends TypeSignature {

    private final int value;

    public IntegerLiteralTypeSignature(int value) {
        super("");
        this.value = value;
    }

    public IntegerLiteralTypeSignature(StreamInput in) throws IOException {
        super(in);
        value = in.readInt();
    }

    public int value() {
        return value;
    }

    @Override
    public void writeTo(StreamOutput out) throws IOException {
        super.writeTo(out);
        out.writeInt(value);
    }

    @Override
    public TypeSignatureType type() {
        return TypeSignatureType.INTEGER_LITERAL_SIGNATURE;
    }

    @Override
    public String toString() {
        return String.valueOf(value);
    }
}
