Guava provides a number of precondition checking utilities. It’s Preconditions
class. You can use it into your project.
Usage
checkArgument(boolean)
Checks that the boolean is true. Use for validating arguments to methods.
checkNotNull(T)
Checks that the value is not null. Returns the value directly, so you can use checkNotNull(value) inline.