Jesse's tweaks to aragos' patch r1063. His patch was quite well implemented and these changes are mostly pedantic.
Most notably, I un-deprecated FactoryProvider, replacing the deprecation tag with an obsolete warning. We should make a best effort to fix deprecated callers before we deprecate something, otherwise we're punishing our users for our own mistakes.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1064 d779f126-a31b-0410-b53b-1d3aecad763e
diff --git a/extensions/assistedinject/src/com/google/inject/assistedinject/BindingCollector.java b/extensions/assistedinject/src/com/google/inject/assistedinject/BindingCollector.java
index 66467f5..e33e6db 100644
--- a/extensions/assistedinject/src/com/google/inject/assistedinject/BindingCollector.java
+++ b/extensions/assistedinject/src/com/google/inject/assistedinject/BindingCollector.java
@@ -18,13 +18,14 @@
import com.google.inject.ConfigurationException;
import com.google.inject.Key;
import com.google.inject.TypeLiteral;
+import com.google.inject.internal.ImmutableSet;
import com.google.inject.internal.Maps;
import com.google.inject.spi.Message;
import java.util.Collections;
import java.util.Map;
/**
- * Utility class for collecting factory bindings. Used for configuring {@link FactoryProvider2}.
+ * Utility class for collecting factory bindings. Used for configuring {@link FactoryProvider2}.
*
* @author schmitt@google.com (Peter Schmitt)
*/
@@ -34,7 +35,7 @@
public BindingCollector addBinding(Key<?> key, TypeLiteral<?> target) {
if (bindings.containsKey(key)) {
- throw new ConfigurationException(Collections.singleton(
+ throw new ConfigurationException(ImmutableSet.of(
new Message("Only one implementation can be specified for " + key)));
}
diff --git a/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryModuleBuilder.java b/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryModuleBuilder.java
index 8561cd4..f01e7ff 100644
--- a/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryModuleBuilder.java
+++ b/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryModuleBuilder.java
@@ -39,11 +39,11 @@
* or <i>newPayment</i>.
*
* <h3>Creating a type that accepts factory parameters</h3>
- * {@code constructedType} is a concrete class with an {@literal @}{@link Inject}-annotated
- * constructor. In addition to injector-supplied parameters, the constructor should have
- * parameters that match each of the factory method's parameters. Each factory-supplied parameter
- * requires an {@literal @}{@link Assisted} annotation. This serves to document that the parameter
- * is not bound by your application's modules.
+ * {@code constructedType} is a concrete class with an {@literal @}{@link com.google.inject.Inject
+ * Inject}-annotated constructor. In addition to injector-supplied parameters, the constructor
+ * should have parameters that match each of the factory method's parameters. Each factory-supplied
+ * parameter requires an {@literal @}{@link Assisted} annotation. This serves to document that the
+ * parameter is not bound by your application's modules.
*
* <pre>public class RealPayment implements Payment {
* {@literal @}Inject
@@ -162,7 +162,6 @@
* .build(AnimalFactory.class));
* }</pre>
*
- *
* @author schmitt@google.com (Peter Schmitt)
*/
public class FactoryModuleBuilder {
diff --git a/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryProvider.java b/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryProvider.java
index 73f7584..09a4505 100755
--- a/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryProvider.java
+++ b/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryProvider.java
@@ -43,7 +43,10 @@
import java.util.Set;
/**
- * Provides a factory that combines the caller's arguments with injector-supplied values to
+ * <strong>Obsolete.</strong> Prefer {@link FactoryModuleBuilder} for its more concise API and
+ * additional capability.
+ *
+ * <p>Provides a factory that combines the caller's arguments with injector-supplied values to
* construct objects.
*
* <h3>Defining a factory</h3>
@@ -139,10 +142,7 @@
* @author jmourits@google.com (Jerome Mourits)
* @author jessewilson@google.com (Jesse Wilson)
* @author dtm@google.com (Daniel Martin)
- *
- * @deprecated Use {@link FactoryModuleBuilder} instead.
*/
-@Deprecated
public class FactoryProvider<F> implements Provider<F>, HasDependencies {
/*
@@ -172,7 +172,7 @@
// Preserving backwards-compatibility: Map all return types in a factory
// interface to the passed implementation type.
Errors errors = new Errors();
- Key implementationKey = Key.get(implementationType);
+ Key<?> implementationKey = Key.get(implementationType);
if (implementationType != null) {
try {
diff --git a/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryProvider2.java b/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryProvider2.java
index 2e6be83..635a0d3 100644
--- a/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryProvider2.java
+++ b/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryProvider2.java
@@ -50,6 +50,7 @@
*
* @author jessewilson@google.com (Jesse Wilson)
* @author dtm@google.com (Daniel Martin)
+ * @author schmitt@google.com (Peter Schmitt)
*/
final class FactoryProvider2<F> implements InvocationHandler, Provider<F> {