Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

Commons Lang: StringUtils

My new favorite method is the equals method on Commons Lang's StringUtils class. It takes the check for null out of your logic and can help you create cleaner code. Before using it you might have to write something like this:

if (request.getParameter("checkbox") != null 
    && (request.getParameter("checkbox").equals("true"))) {

With StringUtils.equals(String, String), you get a little less coding:

if (StringUtils.equals(request.getParameter("checkbox"), "true")) {

If you're using Struts or some other library that already depends on commons-lang, why wouldn't you use it? Possibly performance reasons, but I doubt it causes much of a hit.

Posted in Java at Jan 22 2003, 06:05:51 AM MST 4 Comments
Comments:

Couldn't you just do this? : if ("true".equals(request.getParameter("checkbox"))) { I guess if you're comparing two variables, instead of one varable and one constant(the "true" is never null), the StringUtils.equals is useful.

Posted by James Chochlinski on January 22, 2003 at 07:17 AM MST #

Just dug into commons-lang a bit more and it is really amazing to see the similarity to the code you normally write to get things done. I am now looking through my own code to replace it with commons-lang. I normally use the code that James offers though for equals :)

Posted by Martin van den Bemt on January 22, 2003 at 09:03 AM MST #

And not to be outdone, the isEmpty( str ) and isNotEmpty( str ) methods are handy replacements for the common ( str != null && str.length() > 0 )

Posted by Chris Winters on January 22, 2003 at 09:58 AM MST #

This is very handy indeed. Didn't looked at it before but i'm gonna use it for sure

Posted by Danman on January 22, 2003 at 10:54 AM MST #

Post a Comment:
  • HTML Syntax: Allowed