org.snapscript.core.Constant Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap Show documentation
Show all versions of snap Show documentation
Dynamic scripting for the JVM
package org.snapscript.core;
public class Constant extends Value {
private final Object value;
private final Type type;
public Constant(Object value) {
this(value, null);
}
public Constant(Object value, Type type) {
this.value = value;
this.type = type;
}
@Override
public Type getConstraint() {
return type;
}
@Override
public T getValue() {
return (T)value;
}
@Override
public void setValue(Object value){
throw new InternalStateException("Illegal modification of constant");
}
@Override
public String toString() {
return String.valueOf(value);
}
}