Usage
Objects.equal(Object, Object)
Invoking this method then it will avoid the risking of NullPointerException when we need to compare two object whether they equal.
1 | Objects.equal("a", "a"); // return true; |
Guava provides a number of precondition checking utilities. It’s Preconditions
class. You can use it into your project.
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.
Optional<T>
is a way of replacing a nullable T reference with a non-null value. An Optional may either contain a non-null T reference (in which case we say the reference is “present”), or it may contain nothing (in which case we say the reference is “absent”). It is never said to “contain null.”