All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.javasimon.console.json.SimpleJS Maven / Gradle / Ivy

There is a newer version: 4.2.0
Show newest version
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());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy