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