aboutsummaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorflan <flan@google.com>2014-11-04 07:32:47 -0800
committerSam Berlin <sameb@google.com>2014-11-07 13:18:19 -0500
commitf6189601d44b1ff8143e26337d0704f35f8dc645 (patch)
treedf422fcd32c3c2bb65915c3fbeab7b4a907a4189 /extensions
parent9c8b61815fa15ee3457b9c816afe24a6fdaf7014 (diff)
downloadguice-f6189601d44b1ff8143e26337d0704f35f8dc645.tar.gz
Simplifies MapBinder by moving Key generation to RealMapBinder's constructor.
Tested: All existing tests pass. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=79160583
Diffstat (limited to 'extensions')
-rw-r--r--extensions/multibindings/src/com/google/inject/multibindings/MapBinder.java33
1 files changed, 9 insertions, 24 deletions
diff --git a/extensions/multibindings/src/com/google/inject/multibindings/MapBinder.java b/extensions/multibindings/src/com/google/inject/multibindings/MapBinder.java
index 4e5ec784..f8fd4a3e 100644
--- a/extensions/multibindings/src/com/google/inject/multibindings/MapBinder.java
+++ b/extensions/multibindings/src/com/google/inject/multibindings/MapBinder.java
@@ -143,11 +143,7 @@ public abstract class MapBinder<K, V> {
public static <K, V> MapBinder<K, V> newMapBinder(Binder binder,
TypeLiteral<K> keyType, TypeLiteral<V> valueType) {
binder = binder.skipSources(MapBinder.class, RealMapBinder.class);
- return newMapBinder(binder, keyType, valueType,
- Key.get(mapOf(keyType, valueType)),
- Key.get(mapOfProviderOf(keyType, valueType)),
- Key.get(mapOf(keyType, setOf(valueType))),
- Key.get(mapOfSetOfProviderOf(keyType, valueType)),
+ return newMapBinder(binder, keyType, valueType, Key.get(mapOf(keyType, valueType)),
Multibinder.newSetBinder(binder, entryOfProviderOf(keyType, valueType)));
}
@@ -169,9 +165,6 @@ public abstract class MapBinder<K, V> {
binder = binder.skipSources(MapBinder.class, RealMapBinder.class);
return newMapBinder(binder, keyType, valueType,
Key.get(mapOf(keyType, valueType), annotation),
- Key.get(mapOfProviderOf(keyType, valueType), annotation),
- Key.get(mapOf(keyType, setOf(valueType)), annotation),
- Key.get(mapOfSetOfProviderOf(keyType, valueType), annotation),
Multibinder.newSetBinder(binder, entryOfProviderOf(keyType, valueType), annotation));
}
@@ -193,9 +186,6 @@ public abstract class MapBinder<K, V> {
binder = binder.skipSources(MapBinder.class, RealMapBinder.class);
return newMapBinder(binder, keyType, valueType,
Key.get(mapOf(keyType, valueType), annotationType),
- Key.get(mapOfProviderOf(keyType, valueType), annotationType),
- Key.get(mapOf(keyType, setOf(valueType)), annotationType),
- Key.get(mapOfSetOfProviderOf(keyType, valueType), annotationType),
Multibinder.newSetBinder(binder, entryOfProviderOf(keyType, valueType), annotationType));
}
@@ -247,13 +237,10 @@ public abstract class MapBinder<K, V> {
}
private static <K, V> MapBinder<K, V> newMapBinder(Binder binder,
- TypeLiteral<K> keyType, TypeLiteral<V> valueType,
- Key<Map<K, V>> mapKey, Key<Map<K, Provider<V>>> providerMapKey,
- Key<Map<K, Set<V>>> multimapKey, Key<Map<K, Set<Provider<V>>>> providerMultimapKey,
+ TypeLiteral<K> keyType, TypeLiteral<V> valueType, Key<Map<K, V>> mapKey,
Multibinder<Entry<K, Provider<V>>> entrySetBinder) {
- RealMapBinder<K, V> mapBinder = new RealMapBinder<K, V>(
- binder, keyType, valueType, mapKey, providerMapKey, multimapKey,
- providerMultimapKey, entrySetBinder);
+ RealMapBinder<K, V> mapBinder =
+ new RealMapBinder<K, V>(binder, keyType, valueType, mapKey, entrySetBinder);
binder.install(mapBinder);
return mapBinder;
}
@@ -330,16 +317,14 @@ public abstract class MapBinder<K, V> {
private ImmutableList<Map.Entry<K, Binding<V>>> mapBindings;
private RealMapBinder(Binder binder, TypeLiteral<K> keyType, TypeLiteral<V> valueType,
- Key<Map<K, V>> mapKey, Key<Map<K, Provider<V>>> providerMapKey,
- Key<Map<K, Set<V>>> multimapKey, Key<Map<K, Set<Provider<V>>>> providerMultimapKey,
- Multibinder<Map.Entry<K, Provider<V>>> entrySetBinder) {
+ Key<Map<K, V>> mapKey, Multibinder<Map.Entry<K, Provider<V>>> entrySetBinder) {
this.keyType = keyType;
this.valueType = valueType;
this.mapKey = mapKey;
- this.providerMapKey = providerMapKey;
- this.javaxProviderMapKey = providerMapKey.ofType(mapOfJavaxProviderOf(keyType, valueType));
- this.multimapKey = multimapKey;
- this.providerMultimapKey = providerMultimapKey;
+ this.providerMapKey = mapKey.ofType(mapOfProviderOf(keyType, valueType));
+ this.javaxProviderMapKey = mapKey.ofType(mapOfJavaxProviderOf(keyType, valueType));
+ this.multimapKey = mapKey.ofType(mapOf(keyType, setOf(valueType)));
+ this.providerMultimapKey = mapKey.ofType(mapOfSetOfProviderOf(keyType, valueType));
this.entrySetBinder = (RealMultibinder<Entry<K, Provider<V>>>) entrySetBinder;
this.binder = binder;
this.duplicateKeyErrorMessages = Maps.newHashMap();