Skip to content

Commit

Permalink
Two helper methods
Browse files Browse the repository at this point in the history
These two helper methods are in some other open source libraries but we don't always include those. It bugged me enough that I added them here.

Signed-off-by: Aaron Rosenzweig <[email protected]>
  • Loading branch information
recurve committed Feb 7, 2013
1 parent e762b02 commit 3f67d56
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2789,4 +2789,15 @@ public static String cleanString(String newString, NSArray<String> toBeCleaneds)
return result;
}

public static boolean isBlank(String value) {
boolean isBlank = false;
if (value == null || value.trim().length() == 0) {
isBlank = true;
}
return isBlank;
}

public static boolean isNotBlank(String value) {
return ! isBlank(value);
}
}

4 comments on commit 3f67d56

@rkiddy
Copy link
Member

@rkiddy rkiddy commented on 3f67d56 Feb 8, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you use ERXValueUtilities.isNull? I use that method rather a lot.

@recurve
Copy link
Contributor Author

@recurve recurve commented on 3f67d56 Feb 8, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Ray, I have not used ERXValueUtilities.isNull but thanks for pointing it out. It's interesting that the class comments say it treats whitespace as null but the "isNull()" method does not. I like the "trim()" concept and not letting people type a few spaces to "validate" a field.

@kierankelleher
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apache Commons Lang, which is included in ERJars has methods like these and many more. See StringUtils class. Probably all these Wonder ones should be deprecated in favor of the very well implemented and documented Apache Commons Lang utilities.

Apache Commons Lang StringUtils API

@prabier
Copy link

@prabier prabier commented on 3f67d56 Feb 8, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're completely right. I thought about some times ago and I forgot. Clever.

Please sign in to comment.