package org.grouplens.inject.graph;

import java.lang.reflect.Type;
import java.util.List;

import javax.inject.Provider;

import com.google.common.base.Function;

/**
 * A concrete type. It has a set of dependencies which must be satisfied in
 * order to instantiate it. It can also be viewed as an instantiable extension
 * of {@link Type}.
 * 
 * <p>
 * Nodes are expected to provide a reasonable implementation of
 * {@link #equals(Object)} and {@link #hashCode()} so that they can be
 * de-duplicated, etc.
 * 
 * @author Michael Ekstrand <ekstrand@cs.umn.edu>
 * 
 */
public interface Node {
    /**
     * Get this node's dependencies.
     * 
     * @return A list of dependencies which must be satisfied in order to
     *         instantiate this node.
     */
    List<Desire> getDependencies();
    
    /**
     * Get the type of this node.
     * 
     * @return The type of objects to be instantiated by this node.
     */
    Type getType();

    /**
     * Get the type-erased class of this node's type.
     * @return The class object for this node's type.
     */
    Class<?> getErasedType();
    
    /**
     * Create an instance of the type satisfied by this node.
     * 
     * @param dependencies A function mapping desires to providers of their
     *        instances.
     * @return A new instance of the type represented by this node, with the
     *         specified dependencies injected.
     * @review Consider supporting making Node create {@link Provider}s.
     */
    Object createInstance(Function<Desire, Provider<?>> dependencies);
}

@@ -340,19 +340,15 @@
 e%7D.%0A
- * %0A
  * %3Cp%3E%0A
+
  * N
@@ -503,17 +503,16 @@
  etc.%0A *
- 
 %0A * @aut
@@ -554,20 +554,16 @@
 mn.edu%3E%0A
- * %0A
  */%0Apubl
@@ -625,33 +625,32 @@
 ndencies.%0A     *
- 
 %0A     * @return 
@@ -786,29 +786,25 @@
 ndencies();%0A
-    
 %0A
+
     /**%0A    
@@ -831,33 +831,32 @@
 his node.%0A     *
- 
 %0A     * @return 
@@ -995,24 +995,31 @@
 ode's type.%0A
+     *%0A
      * @retu
@@ -1102,13 +1102,9 @@
 ();%0A
-    
 %0A
+
     
@@ -1126,43 +1126,22 @@
 te a
-n instance of the type satisfied by
+ provider from
  thi
@@ -1154,17 +1154,16 @@
 .%0A     *
- 
 %0A     * 
@@ -1233,24 +1233,37 @@
 their%0A     *
+             
         inst
@@ -1286,16 +1286,28 @@
 eturn A 
+provider of 
 new inst
@@ -1310,16 +1310,17 @@
 instance
+s
  of the 
@@ -1328,17 +1328,15 @@
 ype 
-represent
+specifi
 ed b
@@ -1351,17 +1351,8 @@
 ode,
- with the
 %0A   
@@ -1363,16 +1363,39 @@
         
+instantiated using the 
 specifie
@@ -1409,20 +1409,17 @@
 denc
-ies injected
+y mapping
 .%0A  
@@ -1505,29 +1505,32 @@
     
-Object createInstance
+Provider%3C?%3E makeProvider
 (Fun

Make Node create providers.