Permalink
Browse files

Merge pull request #1100 from ronshapiro/sync-master-05/05/2017

Moe sync
  • Loading branch information...
sameb committed May 9, 2017
2 parents d2f0395 + 702c07e commit e7bef34ef6379735e2a58df1b23f351bb7e30e44
Showing with 7 additions and 29 deletions.
  1. +7 −29 core/src/com/google/inject/internal/InjectorImpl.java
@@ -18,10 +18,11 @@
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.inject.Binder;
@@ -112,7 +113,7 @@ public String toString() {
final State state;
final InjectorImpl parent;
final BindingsMultimap bindingsMultimap = new BindingsMultimap();
final ListMultimap<TypeLiteral<?>, Binding<?>> bindingsMultimap = ArrayListMultimap.create();
final InjectorOptions options;
/** Just-in-time binding cache. Guarded by state.lock() */
@@ -143,17 +144,15 @@ public String toString() {
/** Indexes bindings by type. */
void index() {
for (Binding<?> binding : state.getExplicitBindingsThisLevel().values()) {
index(binding);
bindingsMultimap.put(binding.getKey().getTypeLiteral(), binding);
}
}
<T> void index(Binding<T> binding) {
bindingsMultimap.put(binding.getKey().getTypeLiteral(), binding);
}
@Override
public <T> List<Binding<T>> findBindingsByType(TypeLiteral<T> type) {
return bindingsMultimap.getAll(type);
@SuppressWarnings("unchecked") // safe because we only put matching entries into the map
List<Binding<T>> list = (List<Binding<T>>) (List) bindingsMultimap.get(type);
return Collections.unmodifiableList(list);
}
/** Returns the binding for {@code key} */
@@ -966,27 +965,6 @@ private void removeFailedJitBinding(Binding<?> binding, InjectionPoint ip) {
return ImmutableSet.copyOf(state.getConvertersThisLevel());
}
private static class BindingsMultimap {
final Map<TypeLiteral<?>, List<Binding<?>>> multimap = Maps.newHashMap();
<T> void put(TypeLiteral<T> type, Binding<T> binding) {
List<Binding<?>> bindingsForType = multimap.get(type);
if (bindingsForType == null) {
bindingsForType = Lists.newArrayList();
multimap.put(type, bindingsForType);
}
bindingsForType.add(binding);
}
@SuppressWarnings("unchecked") // safe because we only put matching entries into the map
<T> List<Binding<T>> getAll(TypeLiteral<T> type) {
List<Binding<?>> bindings = multimap.get(type);
return bindings != null
? Collections.<Binding<T>>unmodifiableList((List) multimap.get(type))
: ImmutableList.<Binding<T>>of();
}
}
/** Returns parameter injectors, or {@code null} if there are no parameters. */
SingleParameterInjector<?>[] getParametersInjectors(List<Dependency<?>> parameters, Errors errors)
throws ErrorsException {

0 comments on commit e7bef34

Please sign in to comment.