import java.util.OptionalLong;

/**
 * Parses the deal-seed text from the New Game window. Plain Java, no JavaFX, so
 * it can be unit tested on its own.
 */
public class SeedParser {

	/**
	 * Parses the seed text.
	 *
	 * @param text
	 *          the text the user typed
	 * @return empty if the text is blank (random deal), otherwise the seed
	 * @throws NumberFormatException
	 *           if the text is not a whole number
	 */
	public static OptionalLong parse ( String text ) {
		String t = text.trim();
		if ( t.isEmpty() ) {
			return OptionalLong.empty();
		}
		return OptionalLong.of(Long.parseLong(t));
	}
}