本文整理汇总了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());
}
}
示例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();
}
示例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);
}
}
示例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;
}