Class NullabilityUtil

java.lang.Object
com.ibm.wala.util.nullability.NullabilityUtil

public class NullabilityUtil extends Object
Utility methods for targeted suppressions of NullAway warnings.
  • 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 - if obj is null
    • uncheckedNull

      public static <T extends @Nullable Object> T 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