当前位置: 首页>>代码示例>>Java>>正文


Java Dependency.isNullable方法代码示例

本文整理汇总了Java中com.google.inject.spi.Dependency.isNullable方法的典型用法代码示例。如果您正苦于以下问题:Java Dependency.isNullable方法的具体用法?Java Dependency.isNullable怎么用?Java Dependency.isNullable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.inject.spi.Dependency的用法示例。


在下文中一共展示了Dependency.isNullable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doProvision

import com.google.inject.spi.Dependency; //导入方法依赖的package包/类
@Override
protected T doProvision(InternalContext context, Dependency<?> dependency)
    throws InternalProvisionException {
  try {
    T t = doProvision(SingleParameterInjector.getAll(context, parameterInjectors));
    if (t == null && !dependency.isNullable()) {
      InternalProvisionException.onNullInjectedIntoNonNullableDependency(getMethod(), dependency);
    }
    return t;
  } catch (IllegalAccessException e) {
    throw new AssertionError(e);
  } catch (InvocationTargetException userException) {
    Throwable cause = userException.getCause() != null ? userException.getCause() : userException;
    throw InternalProvisionException.errorInProvider(cause).addSource(getSource());
  }
}
 
开发者ID:google,项目名称:guice,代码行数:17,代码来源:ProviderMethod.java

示例2: checkForNull

import com.google.inject.spi.Dependency; //导入方法依赖的package包/类
/**
 * Returns {@code value} if it is non-null allowed to be null. Otherwise a message is added and
 * an {@code ErrorsException} is thrown.
 */
public <T> T checkForNull(T value, Object source, Dependency<?> dependency)
    throws ErrorsException {
  if (value != null || dependency.isNullable() ) {
    return value;
  }

  int parameterIndex = dependency.getParameterIndex();
  String parameterName = (parameterIndex != -1)
      ? "parameter " + parameterIndex + " of "
      : "";
  addMessage("null returned by binding at %s%n but %s%s is not @Nullable",
      source, parameterName, dependency.getInjectionPoint().getMember());

  throw toException();
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:20,代码来源:Errors.java

示例3: get

import com.google.inject.spi.Dependency; //导入方法依赖的package包/类
@Override
public T get(InternalContext context, Dependency<?> dependency, boolean linked)
    throws InternalProvisionException {
  try {
    T t = provider.get();
    if (t == null && !dependency.isNullable()) {
      InternalProvisionException.onNullInjectedIntoNonNullableDependency(source, dependency);
    }
    return t;
  } catch (RuntimeException userException) {
    throw InternalProvisionException.errorInProvider(userException).addSource(source);
  }
}
 
开发者ID:google,项目名称:guice,代码行数:14,代码来源:InternalFactoryToProviderAdapter.java

示例4: provision

import com.google.inject.spi.Dependency; //导入方法依赖的package包/类
/**
 * Provisions a new instance. Subclasses should override this to catch exceptions & rethrow as
 * ErrorsExceptions.
 */
protected T provision(
    Provider<? extends T> provider,
    Dependency<?> dependency,
    ConstructionContext<T> constructionContext)
    throws InternalProvisionException {
  T t = provider.get();
  if (t == null && !dependency.isNullable()) {
    InternalProvisionException.onNullInjectedIntoNonNullableDependency(source, dependency);
  }
  constructionContext.setProxyDelegates(t);
  return t;
}
 
开发者ID:google,项目名称:guice,代码行数:17,代码来源:ProviderInternalFactory.java


注:本文中的com.google.inject.spi.Dependency.isNullable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。