Nullsafe wrapper for {@code JSType#dereference()}.
187828
private static ObjectType dereferenced(@Nullable JSType type) {
    return type == null ? null : type.dereference();
  }
184099
private static String getTypeDeprecationInfo(JSType type) {
    if (type == null) {
      return null;
    }

    String depReason = getDeprecationReason(type.getJSDocInfo());
    if (depReason != null) {
      return depReason;
    }

    ObjectType objType = castToObject(type);
    if (objType != null) {
      ObjectType implicitProto = objType.getImplicitPrototype();
      if (implicitProto != null) {
        return getTypeDeprecationInfo(implicitProto);
      }
    }
    return null;
  }
375457
private Iterable<? extends JSType> getTypeAlternatives(JSType type) {
    if (type.isUnionType()) {
      return type.getUnionMembers();
    } else {
      ObjectType objType = type.toMaybeObjectType();
      FunctionType constructor = objType != null ? objType.getConstructor() : null;
      if (constructor != null && constructor.isInterface()) {
        List<JSType> list = new ArrayList<>();
        for (FunctionType impl : constructor.getDirectSubTypes()) {
          list.add(impl.getInstanceType());
        }
        return list.isEmpty() ? null : list;
      } else {
        return null;
      }
    }
  }
361263
public static SoyType tryRemoveNull(SoyType soyType) {
    if (soyType == NullType.getInstance()) {
      return NullType.getInstance();
    }
    return removeNull(soyType);
  }
695180
@Nullable
    public static String nullIfBlank(@Nullable String value) {
        if (isBlank(value)) {
            return null;
        }
        return value;
    }
567499
NullSafeAccumulator bracketAccess(Expression arg, boolean nullSafe) {
    chain.add(new Bracket(arg, nullSafe));
    // With a bracket access we no longer need to unpack the entire list, just a singular object.
    accessType = AccessType.SINGULAR;
    return this;
  }
103841
@Deprecated
  @Nullable
  public V get() {
    V value = pop();
    if (value != null) {
      mInUseLength++;
    }
    return value;
  }
1031127
public static <T> T getNotNull(T... ts) {
        if (isNotEmpty(ts)) {
            for (T t : ts) {
                if (isNotNull(t)) {
                    return t;
                }
            }
        }
        return null;
    }
61927
private NullnessAnnotation getMethodNullnessAnnotation() {

        if (method.getSignature().indexOf(")L") >= 0 || method.getSignature().indexOf(")[") >= 0) {
            if (DEBUG_NULLRETURN) {
                System.out.println("Checking return annotation for "
                        + SignatureConverter.convertMethodSignature(classContext.getJavaClass(), method));
            }

            XMethod m = XFactory.createXMethod(classContext.getJavaClass(), method);
            return AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase().getResolvedAnnotation(m, false);
        }
        return NullnessAnnotation.UNKNOWN_NULLNESS;
    }
426955
public static Element getDeclaredElement(TreeNode node) {
    if (node instanceof AbstractTypeDeclaration) {
      return ((AbstractTypeDeclaration) node).getTypeElement();
    } else if (node instanceof MethodDeclaration) {
      return ((MethodDeclaration) node).getExecutableElement();
    } else if (node instanceof VariableDeclaration) {
      return ((VariableDeclaration) node).getVariableElement();
    }
    return null;
  }
1070988
@Override
    public void nullSafeSet(PreparedStatement preparedStatement, Object value, int i, SharedSessionContractImplementor sessionImplementor) throws HibernateException, SQLException {
        // use JDBC array type, which is fairly new, so tread carefully
        if (value == null) {
			preparedStatement.setNull(i, java.sql.Types.ARRAY);
		} else if(value instanceof Integer[]){
		    Integer[] myArray = (Integer[]) value;
            Array inArray = preparedStatement.getConnection().createArrayOf("integer", myArray);
            preparedStatement.setArray(i, inArray);
		} else if(value instanceof int[]) {
			int[] myArray = (int[]) value;
            Array inArray = preparedStatement.getConnection().createArrayOf("integer", wrap(myArray));
			preparedStatement.setArray(i, inArray);
		} else {
		    throw new IllegalArgumentException("Invalid type of input: " + value.getClass().getName());
		}
911716
public static <O extends Object> void notNull(O o) {
		if(!validation) return;
		if(o == null)
			throw new ParameterException(ErrorCode.NULLPOINTER);
	}
707238
private JSType restrictByUndefined(JSType type) {
    // If not voidable, there's nothing to do. If not nullable then the easiest
    // thing is to simply remove both null and undefined. If nullable, then add
    // null back into the union after removing null and undefined.
    if (!type.isVoidable()) {
      return type;
    }
    JSType restricted = type.restrictByNotNullOrUndefined();
    if (type.isNullable()) {
      JSType nullType = registry.getNativeType(JSTypeNative.NULL_TYPE);
      return registry.createUnionType(ImmutableList.of(restricted, nullType));
    }
    // The bottom type cannot appear in a jsdoc
    return restricted.isEmptyType() ? type : restricted;
  }
46688
private SoyValue visitNullSafeNode(ExprNode node) {
    SoyValue value = visitNullSafeNodeRecurse(node);
    // Transform null sentinel into a normal null value.
    if (value == NullSafetySentinel.INSTANCE) {
      return NullData.INSTANCE;
    }
    return value;
  }
123106
@SuppressWarnings("nls")
	private void checkNotNull(Object sourceClass, Object eventSetName, Object alistenerType, Object listenerMethodName)
	{
		if (sourceClass == null)
		{
			throw new NullPointerException(Messages.getString("beans.0C"));
		}
		if (eventSetName == null)
		{
			throw new NullPointerException(Messages.getString("beans.53"));
		}
		if (alistenerType == null)
		{
			throw new NullPointerException(Messages.getString("beans.54"));
		}
		if (listenerMethodName == null)
		{
			throw new NullPointerException(Messages.getString("beans.52"));
		}
	}
907857
private NullSafeAccumulator visitNullSafeNode(ExprNode node) {
    switch (node.getKind()) {
      case FIELD_ACCESS_NODE:
        {
          FieldAccessNode fieldAccess = (FieldAccessNode) node;
          NullSafeAccumulator base = visitNullSafeNode(fieldAccess.getBaseExprChild());
          FieldAccess access =
              genCodeForFieldAccess(
                  fieldAccess.getBaseExprChild().getType(),
                  fieldAccess,
                  fieldAccess.getFieldName());
          return base.dotAccess(access, fieldAccess.isNullSafe());
        }

      case ITEM_ACCESS_NODE:
        {
          ItemAccessNode itemAccess = (ItemAccessNode) node;
          NullSafeAccumulator base = visitNullSafeNode(itemAccess.getBaseExprChild());
          ExprNode keyNode = itemAccess.getKeyExprChild();
          SoyType baseType = itemAccess.getBaseExprChild().getType();
          return SoyTypes.isKindOrUnionOfKind(SoyTypes.removeNull(baseType), Kind.MAP)
              ? base.mapGetAccess(genMapKeyCode(keyNode), itemAccess.isNullSafe()) // soy.Map
              : base.bracketAccess(
                  // The key type may not match JsCompiler's type system (passing number as enum, or
                  // nullable proto field).  I could instead cast this to the map's key type.
                  visit(keyNode).castAs("?"), itemAccess.isNullSafe()); // vanilla bracket access
        }

      default:
        return new NullSafeAccumulator(visit(node));
    }
  }
1003133
@Nullable
  public static Symbol getDeclaredSymbol(Tree tree) {
    if (tree instanceof AnnotationTree) {
      return getSymbol(((AnnotationTree) tree).getAnnotationType());
    }
    if (tree instanceof PackageTree) {
      return getSymbol((PackageTree) tree);
    }
    if (tree instanceof TypeParameterTree) {
      Type type = ((JCTypeParameter) tree).type;
      return type == null ? null : type.tsym;
    }
    if (tree instanceof ClassTree) {
      return getSymbol((ClassTree) tree);
    }
    if (tree instanceof MethodTree) {
      return getSymbol((MethodTree) tree);
    }
    if (tree instanceof VariableTree) {
      return getSymbol((VariableTree) tree);
    }
    return null;
  }