/** * 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; } }
@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); } }
@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()); } }
/** * 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; } }
/** * 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; } }
@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); } }
@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); } }
@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()); } }
@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()); } }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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() || allowNullsBadBadBad) { 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(); }
if (value != null || dependency.isNullable()) { return value;