New method in StringHelpers?

15 views
Skip to first unread message

Jeppe Nejsum Madsen

unread,
Oct 3, 2011, 4:17:16 AM10/3/11
to lif...@googlegroups.com
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

/Jeppe

David Pollak

unread,
Oct 3, 2011, 11:55:38 AM10/3/11
to lif...@googlegroups.com
+1 on adding it.


--
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



--
Lift, the simply functional web framework http://liftweb.net

Naftoli Gugenheim

unread,
Oct 9, 2011, 11:55:22 PM10/9/11
to lif...@googlegroups.com
Of course you can do Full(s) filter (!_.isEmpty) ...


Andreas Joseph Krogh

unread,
Oct 10, 2011, 1:20:41 AM10/10/11
to lif...@googlegroups.com

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

Reply all
Reply to author
Forward
0 new messages