com.google.gwt.inject.rebind.util
Class MethodCallUtil

java.lang.Object
  extended by com.google.gwt.inject.rebind.util.MethodCallUtil

public class MethodCallUtil
extends java.lang.Object

Utility code to create method and constructor calls.


Constructor Summary
MethodCallUtil()
           
 
Method Summary
 SourceSnippet createConstructorInjection(MethodLiteral<?,java.lang.reflect.Constructor<?>> constructor, NameGenerator nameGenerator, java.util.List<InjectorMethod> methodsOutput)
          Creates a constructor injecting method and returns a string that invokes the new method.
 SourceSnippet createMethodCallWithInjection(MethodLiteral<?,?> method, java.lang.String invokeeName, NameGenerator nameGenerator, java.util.List<InjectorMethod> methodsOutput)
          Creates a method that calls the passed method, injecting its parameters using getters, and returns a string that invokes the new method.
 SourceSnippet createMethodCallWithInjection(MethodLiteral<?,?> method, java.lang.String invokeeName, java.lang.String[] parameterNames, NameGenerator nameGenerator, java.util.List<InjectorMethod> methodsOutput)
          Creates a method that calls the passed method, injecting its parameters using getters as necessary, and returns a string that invokes the new method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodCallUtil

public MethodCallUtil()
Method Detail

createConstructorInjection

public SourceSnippet createConstructorInjection(MethodLiteral<?,java.lang.reflect.Constructor<?>> constructor,
                                                NameGenerator nameGenerator,
                                                java.util.List<InjectorMethod> methodsOutput)
                                         throws NoSourceNameException
Creates a constructor injecting method and returns a string that invokes the new method. The new method returns the constructed object.

Parameters:
constructor - constructor to call
nameGenerator - NameGenerator to be used for ensuring method name uniqueness
methodsOutput - a list where all new methods created by this call are added
Returns:
source snippet calling the generated method
Throws:
NoSourceNameException

createMethodCallWithInjection

public SourceSnippet createMethodCallWithInjection(MethodLiteral<?,?> method,
                                                   java.lang.String invokeeName,
                                                   NameGenerator nameGenerator,
                                                   java.util.List<InjectorMethod> methodsOutput)
                                            throws NoSourceNameException
Creates a method that calls the passed method, injecting its parameters using getters, and returns a string that invokes the new method. The new method returns the passed method's return value, if any. If a method without parameters is provided, that method will be called and no parameters will be passed.

Parameters:
method - method to call (can be constructor)
invokeeName - expression that evaluates to the object on which the method is to be called. If null the method will be called in the current scope.
nameGenerator - NameGenerator to be used for ensuring method name uniqueness
methodsOutput - a list where all new methods created by this call are added
Returns:
source snippet calling the generated method
Throws:
NoSourceNameException

createMethodCallWithInjection

public SourceSnippet createMethodCallWithInjection(MethodLiteral<?,?> method,
                                                   java.lang.String invokeeName,
                                                   java.lang.String[] parameterNames,
                                                   NameGenerator nameGenerator,
                                                   java.util.List<InjectorMethod> methodsOutput)
                                            throws NoSourceNameException
Creates a method that calls the passed method, injecting its parameters using getters as necessary, and returns a string that invokes the new method. The new method returns the passed method's return value, if any. If a method without parameters is provided, that method will be called and no parameters will be passed. If the passed method declared any checked exceptions, the generated method will catch and rethrow those as CreationException.

Parameters:
method - method to call (can be constructor)
invokeeName - expression that evaluates to the object on which the method is to be called. If null the method will be called in the current scope.
parameterNames - array with parameter names that can replace getter methods (usually used to fetch injected values) in the returned string. The array length must match the number of method parameters. A null value denotes that the getter method should be used.
nameGenerator - NameGenerator to use for ensuring method name uniqueness
methodsOutput - a list where all new methods created by this call are added
Returns:
string calling the generated method
Throws:
NoSourceNameException