/*
Return exception for trying to use null type outside of a union.
497827
private static IllegalArgumentException nullTypeNotAllowed(ClassTemplateSpec enclosingClass, String memberName)
  {
    return new IllegalArgumentException("The null type can only be used in unions, null found" + enclosingClassAndMemberNameToString(enclosingClass, memberName));
  }
778323
public static void checkNotNull(Object o, String msg, int arg1) {
        if (o == null) {
            throwNullPointerEx(msg, arg1);
        }
    }
329143
@Override
  Nullness visitArrayAccess(ArrayAccessNode node, SubNodeValues inputs, Updates updates) {
    setNonnullIfTrackable(updates, node.getArray());
    return hasPrimitiveType(node) ? NONNULL : defaultAssumption;
  }
990869
public java.lang.String getExternalValuesOrDefault(
      java.lang.String key,
      java.lang.String defaultValue) {
    if (key == null) { throw new java.lang.NullPointerException(); }
    java.util.Map<java.lang.String, java.lang.String> map =
        internalGetExternalValues().getMap();
    return map.containsKey(key) ? map.get(key) : defaultValue;
  }
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;
      }
    }
  }
1213886
public static RuntimeException initCause(RuntimeException ex,
                                             Throwable cause)
    {
        if (Throwable_initCause != null) {
            Object[] args = { cause };
            try {
                Throwable_initCause.invoke(ex, args);
            } catch (Exception e) {
                // Ignore any exceptions
            }
        }
        return ex;
    }
189924
public static SQLException unwrapSQLException(Throwable throwable) {
        if (throwable == null) {
            return null;
        } else if (throwable instanceof SQLException) {
            return (SQLException) throwable;
        } else if (throwable.getCause() != null) {
            // recursive call to unwrap the cause
            return unwrapSQLException(throwable.getCause());
        } else {
            // didn't find any SQLException in the cause stack
            return null;
        }
    }
351672
public static final <T extends JavaScriptObject> T checkNull(T js) {
    if (!GWT.isProdMode() && js == null) {
      throw new NullPointerException();
    }
    return js;
  }
203604
private Description doUnboxingCheck(VisitorState state, ExpressionTree... expressions) {
    for (ExpressionTree tree : expressions) {
      Type type = ASTHelpers.getType(tree);
      if (type == null) {
        throw new RuntimeException("was not expecting null type");
      }
      if (!type.isPrimitive()) {
        if (mayBeNullExpr(state, tree)) {
          final ErrorMessage errorMessage =
              new ErrorMessage(MessageTypes.UNBOX_NULLABLE, "unboxing of a @Nullable value");
          return errorBuilder.createErrorDescription(
              errorMessage, state.getPath(), buildDescription(tree));
        }
      }
    }
    return Description.NO_MATCH;
  }
85326
@SuppressWarnings("unused")
    static Void throwUnsafelyIfNonNull(@Nullable Object unused,
                                       @Nullable Throwable cause) {
        throwUnsafelyIfNonNull(cause);
        return null;
    }
356154
public static <T, X extends RuntimeException> T ifNonNullThrowOrElse(Supplier<X> exceptionSupplier,
            Supplier<T> provider) {
        if (Objects.nonNull(exceptionSupplier)) {
            throw exceptionSupplier.get();
        } else {
            return provider.get();
        }
    }
1355239
public static <T> T validateNotNull(T value, String errorMsgTemplate, Object... params) throws ValidateException {
		if (isNull(value)) {
			throw new ValidateException(errorMsgTemplate, params);
		}
		return value;
	}
859745
public static <T, R, E extends Exception> Nullable<R> ifOrEmpty(final boolean b, final T init, final Try.Function<? super T, R, E> func) throws E {
        if (b) {
            return Nullable.of(func.apply(init));
        } else {
            return Nullable.empty();
        }
    }
452148
public static Double checkNull(Double value, Double elseValue) {
        return isNull(value) ? elseValue : value;
    }
128594
@NonNull
    public static On leftOuterJoin(@NonNull DataSource datasource) {
        if (datasource == null) {
            throw new IllegalArgumentException("datasource cannot be null.");
        }
        return new On(Type.LEFT_OUTER, datasource);
    }
75675
@Override
    public void out() throws Exception {
        Object val = fa.getFieldValue();
//        Object val = access;

        if (ens.shouldFire()) {
            DataflowEvent e = new DataflowEvent(ens.getController(), this, val);
////            DataflowEvent e = new DataflowEvent(ens.getController(), this, access.toObject());
            ens.fireOut(e);
//            // the value might be altered
            val = e.getValue();
        }
        // if data==null this unconsumed @Out, its OK but we do not want to set it.
        if (data != null) {
            data.setFieldValue(val);
        }
        fa.out();
    }
90963
public static <T> T assertNotNull(T object, ExceptionType exceptionType, String message, Object... args) {
        if (object == null) {
            if (exceptionType == null) {
                exceptionType = ExceptionType.ILLEGAL_ARGUMENT;
            }

            throw exceptionType.newInstance(getMessage(message, args,
                                                       "[Assertion failed] - the argument is required; it must not be null"));
        }

        return object;
    }