package com.jfireel.expression.node.impl;

import com.jfireel.expression.node.CalculateNode;
import com.jfireel.expression.token.Token;
import com.jfireel.expression.token.TokenType;

import java.util.Map;

public class VariableNode implements CalculateNode {
	private String literals;

	public VariableNode(String literals) {
		this.literals = literals;
	}

	@Override
	public Object calculate(Map<String, Object> variables) {
		return variables.get(literals);
	}

	@Override
	public TokenType type() {
		return Token.VARIABLE;
	}

	@Override
	public String toString() {
		return "VariableNode [literals=" + literals + "]";
	}

	@Override
	public String literals() {
		return literals;
	}

}
