Class NullabilityUtil
java.lang.Object
com.ibm.wala.util.nullability.NullabilityUtil
Utility methods for targeted suppressions of NullAway warnings.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Exception thrown when acastToNonNull(Object)
call fails. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
castToNonNull
(@Nullable T obj) Casts a reference to a@NonNull
type, throwing an exception if the reference is null.static <T extends @Nullable Object>
TReturns a null reference with a@NonNull
type.
-
Constructor Details
-
NullabilityUtil
public NullabilityUtil()
-
-
Method Details
-
castToNonNull
public static <T> T castToNonNull(@Nullable T obj) throws NullabilityUtil.CastToNonNullFailedException Casts a reference to a@NonNull
type, throwing an exception if the reference is null.- Parameters:
obj
- the reference- Returns:
- the reference itself
- Throws:
NullabilityUtil.CastToNonNullFailedException
- ifobj
is null
-
uncheckedNull
Returns a null reference with a@NonNull
type. Useful, e.g., where a method is allowed to return null, but the NullAway type system can only express a@NonNull
return type.- Returns:
- a null reference
-