I think it makes sense to use commons-lang here. Add the dependency, but make sure to use the same version as Jenkins core.