@Override public Logger get(InternalContext context, Dependency<?> dependency, boolean linked) { InjectionPoint injectionPoint = dependency.getInjectionPoint(); return injectionPoint == null ? Logger.getAnonymousLogger() : Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); }
static String formatParameter(Dependency<?> dependency) { int ordinal = dependency.getParameterIndex() + 1; return String.format( "the %s%s parameter of %s", ordinal, getOrdinalSuffix(ordinal), StackTraceElements.forMember(dependency.getInjectionPoint().getMember())); }
static void formatSource(Formatter formatter, Object source, ElementSource elementSource) { String modules = moduleSourceString(elementSource); if (source instanceof Dependency) { Dependency<?> dependency = (Dependency<?>) source; InjectionPoint injectionPoint = dependency.getInjectionPoint(); if (injectionPoint != null) { formatInjectionPoint(formatter, dependency, injectionPoint, elementSource); } else { formatSource(formatter, dependency.getKey(), elementSource); } } else if (source instanceof InjectionPoint) { formatInjectionPoint(formatter, null, (InjectionPoint) source, elementSource); } else if (source instanceof Class) { formatter.format(" at %s%s%n", StackTraceElements.forType((Class<?>) source), modules); } else if (source instanceof Member) { formatter.format(" at %s%s%n", StackTraceElements.forMember((Member) source), modules); } else if (source instanceof TypeLiteral) { formatter.format(" while locating %s%s%n", source, modules); } else if (source instanceof Key) { Key<?> key = (Key<?>) source; formatter.format(" while locating %s%n", convert(key, elementSource)); } else if (source instanceof Thread) { formatter.format(" in thread %s%n", source); } else { formatter.format(" at %s%s%n", source, modules); } }
throws InternalProvisionException { if (dependency.getInjectionPoint().getMember() instanceof Method) { Method annotated = (Method) dependency.getInjectionPoint().getMember(); if (annotated.isAnnotationPresent(Provides.class)) { switch (InternalFlags.getNullableProvidesOption()) { (dependency.getParameterIndex() != -1) ? Messages.formatParameter(dependency) : StackTraceElements.forMember(dependency.getInjectionPoint().getMember());
for (Dependency dep : deps) { Key<?> depKey = dep.getKey(); InjectionPoint ip = dep.getInjectionPoint(); if (encountered.add(depKey)) { // only check if we haven't looked at this key yet BindingImpl depBinding = jitBindings.get(depKey);
if (dependency.getInjectionPoint().getMember() instanceof Constructor) { if (dependency.getParameterIndex() == 0 && dependency.getKey().equals(keyC1)) { foundC1 = true; fail("Did not expect constructor dependency with key " + dependency.getKey() + " at parameter index " + dependency.getParameterIndex()); } else if (dependency.getInjectionPoint().getMember() instanceof Method) { if (dependency.getKey().equals(keyV1)) { foundV1 = true; fail("Did not expect method dependency with key " + dependency.getKey()); } else if (dependency.getInjectionPoint().getMember() instanceof Field) { if (dependency.getKey().equals(keyF1)) { foundF1 = true;
@Override public Logger get(InternalContext context, Dependency<?> dependency, boolean linked) { InjectionPoint injectionPoint = dependency.getInjectionPoint(); return injectionPoint == null ? Logger.getAnonymousLogger() : Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); }
public Logger get(Errors errors, InternalContext context, Dependency<?> dependency, boolean linked) { InjectionPoint injectionPoint = dependency.getInjectionPoint(); return injectionPoint == null ? Logger.getAnonymousLogger() : Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); }
public Logger get(Errors errors, InternalContext context, Dependency<?> dependency, boolean linked) { InjectionPoint injectionPoint = dependency.getInjectionPoint(); return injectionPoint == null ? Logger.getAnonymousLogger() : Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); }
@Override public Logger get(InternalContext context, Dependency<?> dependency, boolean linked) { InjectionPoint injectionPoint = dependency.getInjectionPoint(); return injectionPoint == null ? Logger.getAnonymousLogger() : Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); }
public Logger get(Errors errors, InternalContext context, Dependency<?> dependency, boolean linked) { InjectionPoint injectionPoint = dependency.getInjectionPoint(); return injectionPoint == null ? Logger.getAnonymousLogger() : Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); }
static Set<Key<?>> getUnboundDirectDependencies(Set<Dependency<?>> dependencies, Set<Key<?>> boundKeys) { Set<Key<?>> unboundKeys = new HashSet<>(); for (Dependency<?> dep : dependencies) { for (Dependency<?> dep2 : dep.getInjectionPoint().getDependencies()) { if (!boundKeys.contains(dep2.getKey())) { unboundKeys.add(dep2.getKey()); } } } return unboundKeys; }
/** * Returns a dependency edge for each {@link Dependency} in the binding. These will be from the * given node ID to the {@link Dependency}'s {@link Key}. * * @param nodeId ID of the node that should be the tail of the dependency edges * @param binding {@link Binding} for the dependencies */ private <T extends Binding<?> & HasDependencies> Collection<Edge> newDependencyEdges( NodeId nodeId, T binding) { ImmutableList.Builder<Edge> builder = ImmutableList.builder(); for (Dependency<?> dependency : binding.getDependencies()) { NodeId to = NodeId.newTypeId(dependency.getKey()); builder.add(new DependencyEdge(nodeId, to, dependency.getInjectionPoint())); } return builder.build(); }
public org.slf4j.Logger get(InternalContext context, Dependency<?> dependency, boolean linked) { InjectionPoint injectionPoint = dependency.getInjectionPoint(); if (injectionPoint != null) { return loggerFactory().getLogger(injectionPoint.getMember().getDeclaringClass().getName()); } return loggerFactory().getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); }
static String formatParameter(Dependency<?> dependency) { int ordinal = dependency.getParameterIndex() + 1; return String.format( "the %s%s parameter of %s", ordinal, getOrdinalSuffix(ordinal), StackTraceElements.forMember(dependency.getInjectionPoint().getMember())); }
static String formatParameter(Dependency<?> dependency) { int ordinal = dependency.getParameterIndex() + 1; return String.format( "the %s%s parameter of %s", ordinal, getOrdinalSuffix(ordinal), StackTraceElements.forMember(dependency.getInjectionPoint().getMember())); }
/** * Returns a new instance node for the given {@link Binding}. * * @param binding binding for the node to create * @param instance value of the instance * @return instance node for the given binding */ private <T extends Binding<?> & HasDependencies> InstanceNode newInstanceNode( T binding, Object instance) { Collection<Member> members = Lists.newArrayList(); for (Dependency<?> dependency : binding.getDependencies()) { InjectionPoint injectionPoint = dependency.getInjectionPoint(); if (injectionPoint != null) { members.add(injectionPoint.getMember()); } } return new InstanceNode( NodeId.newInstanceId(binding.getKey()), binding.getSource(), instance, members); }
/** * 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(); }