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

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

public class NameGenerator
extends java.lang.Object

Helper to generate various names for members of a Ginjector implementation.


Constructor Summary
NameGenerator()
           
 
Method Summary
 java.lang.String convertToValidMemberName(java.lang.String name)
           
 java.lang.String createMethodName(java.lang.String base)
          Returns a new valid (i.e.
 java.lang.String getAssistedInjectMethodName(Key<?> factoryKey, java.lang.String methodName)
          Returns the name of an assisted injection helper method.
 java.lang.String getChildInjectorGetterMethodName(java.lang.String childInjectorClassName)
          Returns the name of a getter for a child injector.
 java.lang.String getFragmentCanonicalClassName(java.lang.String injectorClassName, FragmentPackageName fragmentPackageName)
          Computes the canonical name (including package) of a single fragment of a Ginjector.
 java.lang.String getFragmentClassName(java.lang.String injectorClassName, FragmentPackageName fragmentPackageName)
          Computes the name of a single fragment of a Ginjector.
 java.lang.String getFragmentFieldName(FragmentPackageName fragmentPackageName)
          Computes the field name of a single fragment of an injector.
 java.lang.String getFragmentGetterMethodName(FragmentPackageName fragmentPackageName)
          Returnst he name of a getter for an injector fragment.
 java.lang.String getGetterMethodName(Key<?> key)
          Returns the key's getter method name.
 java.lang.String getGinjectorInterfaceFieldName()
          Computes the name of the field in which the Ginjector interface implementation is stored.
 java.lang.String getGinjectorInterfaceGetterMethodName()
          Computes the name of the method used to retrieve the Ginjector interface implementation.
 java.lang.String getMemberInjectMethodName(TypeLiteral<?> type)
          Returns the type's member inject method name.
 java.lang.String getSingletonFieldName(Key<?> key)
          Returns the key's singleton field name.
 void markAsUsed(java.lang.String name)
          Reserves the given name to prevent new methods to be created with it.
static java.lang.String replaceLast(java.lang.String source, char toReplace, char with)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NameGenerator

public NameGenerator()
Method Detail

getAssistedInjectMethodName

public java.lang.String getAssistedInjectMethodName(Key<?> factoryKey,
                                                    java.lang.String methodName)
Returns the name of an assisted injection helper method.


getChildInjectorGetterMethodName

public java.lang.String getChildInjectorGetterMethodName(java.lang.String childInjectorClassName)
Returns the name of a getter for a child injector.


getFragmentGetterMethodName

public java.lang.String getFragmentGetterMethodName(FragmentPackageName fragmentPackageName)
Returnst he name of a getter for an injector fragment.


getGetterMethodName

public java.lang.String getGetterMethodName(Key<?> key)
Returns the key's getter method name. The method with that name can be called to retrieve an instance of the type described by the key.

Returns:
getter method name

getFragmentClassName

public java.lang.String getFragmentClassName(java.lang.String injectorClassName,
                                             FragmentPackageName fragmentPackageName)
Computes the name of a single fragment of a Ginjector.

Parameters:
injectorClassName - the simple name of the injector's class (not including its package)

getFragmentCanonicalClassName

public java.lang.String getFragmentCanonicalClassName(java.lang.String injectorClassName,
                                                      FragmentPackageName fragmentPackageName)
Computes the canonical name (including package) of a single fragment of a Ginjector.


getFragmentFieldName

public java.lang.String getFragmentFieldName(FragmentPackageName fragmentPackageName)
Computes the field name of a single fragment of an injector.


getGinjectorInterfaceFieldName

public java.lang.String getGinjectorInterfaceFieldName()
Computes the name of the field in which the Ginjector interface implementation is stored.


getGinjectorInterfaceGetterMethodName

public java.lang.String getGinjectorInterfaceGetterMethodName()
Computes the name of the method used to retrieve the Ginjector interface implementation.


getMemberInjectMethodName

public java.lang.String getMemberInjectMethodName(TypeLiteral<?> type)
Returns the type's member inject method name. The method with that name can be called with a single parameter to inject members of that parameter.

Returns:
member inject method name

getSingletonFieldName

public java.lang.String getSingletonFieldName(Key<?> key)
Returns the key's singleton field name.

Returns:
singleton field name

createMethodName

public java.lang.String createMethodName(java.lang.String base)
Returns a new valid (i.e. unique) method name based on base. Note: Method names are considered "used" after being returned by this method, whether they're actually used to write a new method or not.

Parameters:
base - base on which method name gets created
Returns:
valid method name

markAsUsed

public void markAsUsed(java.lang.String name)
                throws java.lang.IllegalArgumentException
Reserves the given name to prevent new methods to be created with it.

Parameters:
name - name to be reserved
Throws:
java.lang.IllegalArgumentException

convertToValidMemberName

public java.lang.String convertToValidMemberName(java.lang.String name)

replaceLast

public static java.lang.String replaceLast(java.lang.String source,
                                           char toReplace,
                                           char with)