org.javasimon.console.json.SimpleJS Maven / Gradle / Ivy
package org.javasimon.console.json;
import java.io.IOException;
import java.io.Writer;
import org.javasimon.console.text.Stringifier;
/**
* JavaScript simple type.
*
* @author gquintana
*/
public class SimpleJS extends AnyJS {
/** Simple value. */
protected final T value;
/** Value formatter. */
protected final Stringifier valueStringifier;
// TODO how hidden is this?
/** Hidden constructor use factory methods instead. */
public SimpleJS(T value, Stringifier valueStringifier) {
this.value = value;
this.valueStringifier = valueStringifier;
}
public T getValue() {
return value;
}
public String getFormattedValue() {
return valueStringifier.toString(value);
}
@Override
public void write(Writer writer) throws IOException {
writer.write(getFormattedValue());
}
}