Start adding standard StringConverter
s
This commit is contained in:
parent
bd1201ca28
commit
0660143ae4
@ -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(""))
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user