@Override @SuppressWarnings("unchecked") public T get(Errors errors, InternalContext context, Dependency<?> dependency) throws ErrorsException { if (constructorInjector == null) { throw new IllegalStateException("Constructor not ready"); } // This may not actually be safe because it could return a super type of T (if that's all the // client needs), but it should be OK in practice thanks to the wonders of erasure. return (T) constructorInjector.construct(errors, context, dependency.getKey().getRawType()); } }
<T> SingleParameterInjector<T> createParameterInjector(final Dependency<T> dependency, final Errors errors) throws ErrorsException { InternalFactory<? extends T> factory = getInternalFactory(dependency.getKey(), errors); return new SingleParameterInjector<>(dependency, factory); }
SingleFieldInjector(InjectorImpl injector, InjectionPoint injectionPoint, Errors errors) throws ErrorsException { this.injectionPoint = injectionPoint; this.field = (Field) injectionPoint.getMember(); this.dependency = injectionPoint.getDependencies().get(0); factory = injector.getInternalFactory(dependency.getKey(), errors); }
public static void formatInjectionPoint(Formatter formatter, Dependency<?> dependency, InjectionPoint injectionPoint) { Member member = injectionPoint.getMember(); Class<? extends Member> memberType = MoreTypes.memberType(member); if (memberType == Field.class) { dependency = injectionPoint.getDependencies().get(0); formatter.format(" while locating %s%n", convert(dependency.getKey())); formatter.format(" for field at %s%n", StackTraceElements.forMember(member)); } else if (dependency != null) { formatter.format(" while locating %s%n", convert(dependency.getKey())); formatter.format(" for parameter %s at %s%n", dependency.getParameterIndex(), StackTraceElements.forMember(member)); } else { formatSource(formatter, injectionPoint.getMember()); } } }
public static void formatSource(Formatter formatter, Object source) { if (source instanceof Dependency) { Dependency<?> dependency = (Dependency<?>) source; InjectionPoint injectionPoint = dependency.getInjectionPoint(); if (injectionPoint != null) { formatInjectionPoint(formatter, dependency, injectionPoint); } else { formatSource(formatter, dependency.getKey()); } } else if (source instanceof InjectionPoint) { formatInjectionPoint(formatter, null, (InjectionPoint) source); } else if (source instanceof Class) { formatter.format(" at %s%n", StackTraceElements.forType((Class<?>) source)); } else if (source instanceof Member) { formatter.format(" at %s%n", StackTraceElements.forMember((Member) source)); } else if (source instanceof TypeLiteral) { formatter.format(" while locating %s%n", source); } else if (source instanceof Key) { Key<?> key = (Key<?>) source; formatter.format(" while locating %s%n", convert(key)); } else { formatter.format(" at %s%n", source); } }
@Override @SuppressWarnings("unchecked") public T get(Errors errors, InternalContext context, Dependency<?> dependency) throws ErrorsException { if (constructorInjector == null) { throw new IllegalStateException("Constructor not ready"); } // This may not actually be safe because it could return a super type of T (if that's all the // client needs), but it should be OK in practice thanks to the wonders of erasure. return (T) constructorInjector.construct(errors, context, dependency.getKey().getRawType()); } }
@Override @SuppressWarnings("unchecked") public T get(Errors errors, InternalContext context, Dependency<?> dependency) throws ErrorsException { if (constructorInjector == null) { throw new IllegalStateException("Constructor not ready"); } // This may not actually be safe because it could return a super type of T (if that's all the // client needs), but it should be OK in practice thanks to the wonders of erasure. return (T) constructorInjector.construct(errors, context, dependency.getKey().getRawType()); } }
@Override @SuppressWarnings("unchecked") public T get(Errors errors, InternalContext context, Dependency<?> dependency) throws ErrorsException { if (constructorInjector == null) { throw new IllegalStateException("Constructor not ready"); } // This may not actually be safe because it could return a super type of T (if that's all the // client needs), but it should be OK in practice thanks to the wonders of erasure. return (T) constructorInjector.construct(errors, context, dependency.getKey().getRawType()); } }
<T> SingleParameterInjector<T> createParameterInjector(final Dependency<T> dependency, final Errors errors) throws ErrorsException { InternalFactory<? extends T> factory = getInternalFactory(dependency.getKey(), errors); return new SingleParameterInjector<>(dependency, factory); }
<T> SingleParameterInjector<T> createParameterInjector(final Dependency<T> dependency, final Errors errors) throws ErrorsException { InternalFactory<? extends T> factory = getInternalFactory(dependency.getKey(), errors); return new SingleParameterInjector<>(dependency, factory); }
<T> SingleParameterInjector<T> createParameterInjector(final Dependency<T> dependency, final Errors errors) throws ErrorsException { InternalFactory<? extends T> factory = getInternalFactory(dependency.getKey(), errors); return new SingleParameterInjector<>(dependency, factory); }
<T> SingleParameterInjector<T> createParameterInjector(final Dependency<T> dependency, final Errors errors) throws ErrorsException { InternalFactory<? extends T> factory = getInternalFactory(dependency.getKey(), errors); return new SingleParameterInjector<>(dependency, factory); }
SingleFieldInjector(InjectorImpl injector, InjectionPoint injectionPoint, Errors errors) throws ErrorsException { this.injectionPoint = injectionPoint; this.field = (Field) injectionPoint.getMember(); this.dependency = injectionPoint.getDependencies().get(0); factory = injector.getInternalFactory(dependency.getKey(), errors); }
SingleFieldInjector(InjectorImpl injector, InjectionPoint injectionPoint, Errors errors) throws ErrorsException { this.injectionPoint = injectionPoint; this.field = (Field) injectionPoint.getMember(); this.dependency = injectionPoint.getDependencies().get(0); factory = injector.getInternalFactory(dependency.getKey(), errors); }
SingleFieldInjector(InjectorImpl injector, InjectionPoint injectionPoint, Errors errors) throws ErrorsException { this.injectionPoint = injectionPoint; this.field = (Field) injectionPoint.getMember(); this.dependency = injectionPoint.getDependencies().get(0); factory = injector.getInternalFactory(dependency.getKey(), errors); }
public SingleFieldInjector(InjectorImpl injector, InjectionPoint injectionPoint, Errors errors) throws ErrorsException { this.injectionPoint = injectionPoint; this.field = (Field) injectionPoint.getMember(); this.dependency = injectionPoint.getDependencies().get(0); factory = injector.getInternalFactory(dependency.getKey(), errors); }
@Override @SuppressWarnings("unchecked") public T get(Errors errors, InternalContext context, Dependency<?> dependency) throws ErrorsException { checkState(constructorInjector != null, "Constructor not ready"); // This may not actually be safe because it could return a super type of T (if that's all the // client needs), but it should be OK in practice thanks to the wonders of erasure. return (T) constructorInjector.construct(errors, context, dependency.getKey().getRawType()); } }
public static void formatInjectionPoint(Formatter formatter, Dependency<?> dependency, InjectionPoint injectionPoint) { Member member = injectionPoint.getMember(); Class<? extends Member> memberType = MoreTypes.memberType(member); if (memberType == Field.class) { dependency = injectionPoint.getDependencies().get(0); formatter.format(" while locating %s%n", convert(dependency.getKey())); formatter.format(" for field at %s%n", StackTraceElements.forMember(member)); } else if (dependency != null) { formatter.format(" while locating %s%n", convert(dependency.getKey())); formatter.format(" for parameter %s at %s%n", dependency.getParameterIndex(), StackTraceElements.forMember(member)); } else { formatSource(formatter, injectionPoint.getMember()); } } }
public static void formatInjectionPoint(Formatter formatter, Dependency<?> dependency, InjectionPoint injectionPoint) { Member member = injectionPoint.getMember(); Class<? extends Member> memberType = MoreTypes.memberType(member); if (memberType == Field.class) { dependency = injectionPoint.getDependencies().get(0); formatter.format(" while locating %s%n", convert(dependency.getKey())); formatter.format(" for field at %s%n", StackTraceElements.forMember(member)); } else if (dependency != null) { formatter.format(" while locating %s%n", convert(dependency.getKey())); formatter.format(" for parameter %s at %s%n", dependency.getParameterIndex(), StackTraceElements.forMember(member)); } else { formatSource(formatter, injectionPoint.getMember()); } } }
public static void formatInjectionPoint(Formatter formatter, Dependency<?> dependency, InjectionPoint injectionPoint) { Member member = injectionPoint.getMember(); Class<? extends Member> memberType = MoreTypes.memberType(member); if (memberType == Field.class) { dependency = injectionPoint.getDependencies().get(0); formatter.format(" while locating %s%n", convert(dependency.getKey())); formatter.format(" for field at %s%n", StackTraceElements.forMember(member)); } else if (dependency != null) { formatter.format(" while locating %s%n", convert(dependency.getKey())); formatter.format(" for parameter %s at %s%n", dependency.getParameterIndex(), StackTraceElements.forMember(member)); } else { formatSource(formatter, injectionPoint.getMember()); } } }