I frequently find myself writing this method:
def emptyForBlank(in: String) = emptyForNull(in).trim match {
case "" => Empty
case s => Full(s)
}
Is something like this already in Lift? Couldn't find it....
Should we add it to StringHelpers? If so, I would like to rename
emptyForNull to blankForNull so as not to confuse the empty string
("") with Box.empty
/Jeppe
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code
På mandag 10. oktober 2011 kl 05:55:22 skrev Naftoli Gugenheim <nafto...@gmail.com>:
Of course you can do Full(s) filter (!_.isEmpty) ...
On Mon, Oct 3, 2011 at 4:17 AM, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:
Hi
I frequently find myself writing this method:
def emptyForBlank(in: String) = emptyForNull(in).trim match {
case "" => Empty
case s => Full(s)
}
Is something like this already in Lift? Couldn't find it....
Should we add it to StringHelpers? If so, I would like to rename
emptyForNull to blankForNull so as not to confuse the empty string
("") with Box.empty
I simply use StirngUtils from apache-commons: StringUtils.isBlank(s), you can "static import" it, to be able to use just isBlank(s).
--
Andreas Joseph Krogh <and...@officenet.no> - mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc