ProviderBindingImpl(InjectorImpl injector, Key<Provider<T>> key, Binding<T> providedBinding) { super( injector, key, providedBinding.getSource(), createInternalFactory(providedBinding), Scoping.UNSCOPED); this.providedBinding = (BindingImpl<T>) providedBinding; }
private static <K, V> InternalProvisionException createNullValueException( K key, Binding<V> binding) { return InternalProvisionException.create( "Map injection failed due to null value for key \"%s\", bound at: %s", key, binding.getSource()); } }
private InternalProvisionException newNullEntryException(int i) { return InternalProvisionException.create( "Set injection failed due to null element bound at: %s", bindings.get(i).getSource()); }
private static <K, V> void reportDuplicateKeysError( Multimap<K, Binding<V>> duplicates, Errors errors) { StringBuilder sb = new StringBuilder("Map injection failed due to duplicated key "); boolean first = true; for (Map.Entry<K, Collection<Binding<V>>> entry : duplicates.asMap().entrySet()) { K dupKey = entry.getKey(); if (first) { first = false; sb.append("\"" + dupKey + "\", from bindings:\n"); } else { sb.append("\n and key: \"" + dupKey + "\", from bindings:\n"); } for (Binding<V> dup : entry.getValue()) { sb.append("\t at " + Errors.convert(dup.getSource()) + "\n"); } } // TODO(user): Add a different error for every duplicated key errors.addMessage(sb.toString()); }
@Override public <T> Void visit(Binding<T> binding) { if (!overriddenKeys.remove(binding.getKey())) { super.visit(binding); // Record when a scope instance is used in a binding Scope scope = getScopeInstanceOrNull(binding); if (scope != null) { List<Object> existing = scopeInstancesInUse.get(scope); if (existing == null) { existing = Lists.newArrayList(); scopeInstancesInUse.put(scope, existing); } existing.add(binding.getSource()); } } return null; }
ConvertedConstantBindingImpl( InjectorImpl injector, Key<T> key, T value, Binding<String> originalBinding, TypeConverterBinding typeConverterBinding) { super( injector, key, originalBinding.getSource(), new ConstantFactory<T>(Initializables.of(value)), Scoping.UNSCOPED); this.value = value; provider = Providers.of(value); this.originalBinding = originalBinding; this.typeConverterBinding = typeConverterBinding; }
if (have.contains(want) || want.contains(have)) { Formatter fmt = new Formatter(); Messages.formatSource(fmt, bindingMap.get(bindingKey).getSource()); String match = String.format("%s bound%s", convert(bindingKey), fmt.toString()); possibleMatches.add(match);
ProviderBindingImpl(InjectorImpl injector, Key<Provider<T>> key, Binding<T> providedBinding) { super( injector, key, providedBinding.getSource(), createInternalFactory(providedBinding), Scoping.UNSCOPED); this.providedBinding = (BindingImpl<T>) providedBinding; }
private static <K, V> InternalProvisionException createNullValueException( K key, Binding<V> binding) { return InternalProvisionException.create( "Map injection failed due to null value for key \"%s\", bound at: %s", key, binding.getSource()); } }
private static <K, V> InternalProvisionException createNullValueException( K key, Binding<V> binding) { return InternalProvisionException.create( "Map injection failed due to null value for key \"%s\", bound at: %s", key, binding.getSource()); } }
ProviderBindingImpl(InjectorImpl injector, Key<Provider<T>> key, Binding<T> providedBinding) { super(injector, key, providedBinding.getSource(), createInternalFactory(providedBinding), Scoping.UNSCOPED); this.providedBinding = (BindingImpl<T>) providedBinding; }
ProviderBindingImpl(InjectorImpl injector, Key<Provider<T>> key, Binding<T> providedBinding) { super(injector, key, providedBinding.getSource(), createInternalFactory(providedBinding), Scoping.UNSCOPED); this.providedBinding = (BindingImpl<T>) providedBinding; }
ProviderBindingImpl(InjectorImpl injector, Key<Provider<T>> key, Binding<T> providedBinding) { super(injector, key, providedBinding.getSource(), createInternalFactory(providedBinding), Scoping.UNSCOPED); this.providedBinding = (BindingImpl<T>) providedBinding; }
protected Void visitOther(com.google.inject.Binding<? extends T> binding) { messages.add(new Message(binding.getSource(), PrettyPrinter.format( "Unsupported binding provided for key: %s: %s", targetKey, binding))); return null; }
public String getDescription() { final Object source = bean.getBinding().getSource(); if ( source instanceof PlexusBeanDescription ) { return ( (PlexusBeanDescription) source ).getDescription(); } return null; }
private <T> InternalFactory<T> handleConstantConversionError( Member member, Binding<String> stringBinding, Class<?> rawType, Exception e) { errorHandler.handle( StackTraceElements.forMember(member), ErrorMessages.CONSTANT_CONVERSION_ERROR, stringBinding.getSource(), rawType, e.getMessage()); return invalidFactory(); }
public void testImportSource() { final Injector injector = Guice.createInjector( new WireModule( new TestModule() ) ); assertEquals( LocatorWiring.class.getName(), injector.getBinding( Y.class ).getSource().toString() ); }
/** * Returns a new implementation node for the given binding. * * @param binding binding for the node to create * @param members members to add to the node * @return implementation node for the given binding */ private ImplementationNode newImplementationNode( Binding<?> binding, Collection<Member> members) { return new ImplementationNode( NodeId.newTypeId(binding.getKey()), binding.getSource(), members); }