Start adding standard StringConverters

This commit is contained in:
Sarah Gerweck 2016-07-14 01:57:33 -07:00
parent bd1201ca28
commit 0660143ae4

View File

@ -0,0 +1,14 @@
package org.gerweck.scalafx.util
import scalafx.util.StringConverter
/** A collection of premade string converters.
*
* @author Sarah Gerweck <sarah@atscale.com>
*/
object StringConverters {
/** A converter for an `Option[String]` that treats empty strings (or those
* with only whitespace) as `None`.
*/
lazy val OptionStringConverter = StringConverter[Option[String]](s => if (s.trim.isEmpty) None else Some(s), _.getOrElse(""))
}