3 Answers
3

If you, for some reason, don't want to include commons-lang, here's the code of that method. But it is a better option to just include the dependency - it has many extras that you will eventually need.

+1, though I'd recommend just using commons-lang rather than using the method outlined here (especially if the project is still growing.) I always used to copy code like this rather than using commons-lang, but as the codebase grew I inevitably copied other methods until I might just as well have included it from the start. If you find you need to remove the dependency later and it only uses this one method then that won't be too hard, but I'd advise just leaving it in. A lot of projects depend on commons-lang, and for good reason!
–
berry120Feb 1 '11 at 14:18

If this is the actual code in commons-lang, shouldn't you at least refer to the copyright license?
–
IshtarFeb 1 '11 at 14:21

1

@Ishtar - it is the code decompiled from my decompiler and formatted by me :) I guess it is enough to mention where the code comes from. It's not some rocket science, I could've written it, but just saved some time. And the license header is rather long, it will make the answer look bad.
–
BozhoFeb 1 '11 at 14:23

The most common source of bugs with boxed values is probably that they can be null, while primitives can't. This could lead to NullPointerExceptions in unexpected places.
–
Sergey TachenovFeb 1 '11 at 14:42