spoon.reflect.factory
Class MethodFactory

Package class diagram package MethodFactory
java.lang.Object
  extended by spoon.reflect.factory.SubFactory
      extended by spoon.reflect.factory.ExecutableFactory
          extended by spoon.reflect.factory.MethodFactory
All Implemented Interfaces:
java.io.Serializable, FactoryAccessor

public class MethodFactory
extends ExecutableFactory

The CtMethod sub-factory.

See Also:
Serialized Form

Constructor Summary
MethodFactory(Factory factory)
          Creates a new method sub-factory.
 
Method Summary
<R,B extends R>
CtMethod<R>
create(CtClass<?> target, java.util.Set<ModifierKind> modifiers, CtTypeReference<R> returnType, java.lang.String name, java.util.List<CtParameter<?>> parameters, java.util.Set<CtTypeReference<? extends java.lang.Throwable>> thrownTypes, CtBlock<B> body)
          Creates a method.
<T> CtMethod<T>
create(CtType<?> target, CtMethod<T> source, boolean redirectReferences)
          Creates a method by copying an existing method.
<T> CtMethod<T>
create(CtType<?> target, java.util.Set<ModifierKind> modifiers, CtTypeReference<T> returnType, java.lang.String name, java.util.List<CtParameter<?>> parameters, java.util.Set<CtTypeReference<? extends java.lang.Throwable>> thrownTypes)
          Creates an empty method.
<T> CtExecutableReference<T>
createReference(CtMethod<T> m)
          Creates a method reference.
<T> CtExecutableReference<T>
createReference(java.lang.reflect.Method method)
          Creates a method reference from an actual method.
 java.util.Collection<CtMethod<java.lang.Void>> getMainMethods()
          Gets all the main methods stored in this factory.
 
Methods inherited from class spoon.reflect.factory.ExecutableFactory
createAnonymous, createParameter, createParameterReference, createReference, createReference, createReference, createReference, createReference, createReference
 
Methods inherited from class spoon.reflect.factory.SubFactory
getFactory, setFactory, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodFactory

public MethodFactory(Factory factory)
Creates a new method sub-factory.

Parameters:
factory - the parent factory
Method Detail

create

public <R,B extends R> CtMethod<R> create(CtClass<?> target,
                                          java.util.Set<ModifierKind> modifiers,
                                          CtTypeReference<R> returnType,
                                          java.lang.String name,
                                          java.util.List<CtParameter<?>> parameters,
                                          java.util.Set<CtTypeReference<? extends java.lang.Throwable>> thrownTypes,
                                          CtBlock<B> body)
Creates a method.

Parameters:
target - the class where the method is inserted
modifiers - the modifiers
returnType - the method's return type
name - the method's name
parameters - the parameters
thrownTypes - the thrown types
body - the method's body

create

public <T> CtMethod<T> create(CtType<?> target,
                              CtMethod<T> source,
                              boolean redirectReferences)
Creates a method by copying an existing method.

Type Parameters:
T - the type of the method
Parameters:
target - the target type where the new method has to be inserted to
source - the source method to be copied
redirectReferences - tells if all the references to the owning type of the source method should be redirected to the target type (true is recommended for most uses)
Returns:
the newly created method

create

public <T> CtMethod<T> create(CtType<?> target,
                              java.util.Set<ModifierKind> modifiers,
                              CtTypeReference<T> returnType,
                              java.lang.String name,
                              java.util.List<CtParameter<?>> parameters,
                              java.util.Set<CtTypeReference<? extends java.lang.Throwable>> thrownTypes)
Creates an empty method.

Parameters:
target - the class where the method is inserted
modifiers - the modifiers
returnType - the method's return type
name - the method's name
parameters - the parameters
thrownTypes - the thrown types

createReference

public <T> CtExecutableReference<T> createReference(CtMethod<T> m)
Creates a method reference.


createReference

public <T> CtExecutableReference<T> createReference(java.lang.reflect.Method method)
Creates a method reference from an actual method.


getMainMethods

public java.util.Collection<CtMethod<java.lang.Void>> getMainMethods()
Gets all the main methods stored in this factory.