Lang-1345 Enhance non-empty strings #278
For me is not clear importance of the new methods. I can't remember situations when I needed for something like this. And even if I need something like this I'll write the function myself and I'll not even think about to search something in Commons Lang library. Time spent to looking for the method will be ten time more then write myself.
It would be great if you can give us an examples of usage and how they are important.
A typical case would be that you're assembling a sentence, and if a component is not empty, you need to add a space beforehand. (Sometimes
Or you're building a URL, and if there's a non-blank query string, you need to put a question mark before it.
Really, any situation where part of a string is optional but requires special formatting if present.
@garydgregory The trouble with "default" names is that this functionality is the opposite. The defaultXXX methods have the logic, "if present, leave untouched; otherwise use the second parameter." This would instead be, "if present, apply the second parameter; otherwise, leave untouched." Could use "appendIfNotXXX" and "prependIfNotXXX" I suppose, but I'd rather combine prefixes and suffixes in one method.