Class NullnessUtils

java.lang.Object
com.google.errorprone.bugpatterns.nullness.NullnessUtils

public final class NullnessUtils extends Object
Static utility methods for common functionality in the nullable checkers.
Author:
awturner@google.com (Andy Turner)
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    hasDefinitelyNullBranch(ExpressionTree tree, Set<com.sun.tools.javac.code.Symbol.VarSymbol> definitelyNullVars, com.google.common.collect.ImmutableSet<Name> varsProvenNullByParentIf, VisitorState stateForCompilationUnit)
    Returns true if the given expression can definitely evaluate to null along at least one execution branch (for example, explicit null literals, conditional/ternary branches returning null, known-null variables, or calls to methods like Optional.orNull()).
    static com.google.common.collect.ImmutableSet<Name>
    Returns x if the path's leaf is inside (x == null) ? ... : ....

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • hasDefinitelyNullBranch

      public static boolean hasDefinitelyNullBranch(ExpressionTree tree, Set<com.sun.tools.javac.code.Symbol.VarSymbol> definitelyNullVars, com.google.common.collect.ImmutableSet<Name> varsProvenNullByParentIf, VisitorState stateForCompilationUnit)
      Returns true if the given expression can definitely evaluate to null along at least one execution branch (for example, explicit null literals, conditional/ternary branches returning null, known-null variables, or calls to methods like Optional.orNull()).
    • varsProvenNullByParentTernary

      public static com.google.common.collect.ImmutableSet<Name> varsProvenNullByParentTernary(TreePath path)
      Returns x if the path's leaf is inside (x == null) ? ... : ....