Package spoon.reflect.factory
Class MethodFactory
java.lang.Object
spoon.reflect.factory.SubFactory
spoon.reflect.factory.ExecutableFactory
spoon.reflect.factory.MethodFactory
The
CtMethod
sub-factory.-
Field Summary
Fields inherited from class spoon.reflect.factory.SubFactory
factory
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<R, B extends R>
CtMethod<R>create(CtClass<?> target, Set<ModifierKind> modifiers, CtTypeReference<R> returnType, String name, List<CtParameter<?>> parameters, Set<CtTypeReference<? extends Throwable>> thrownTypes, CtBlock<B> body)
Creates a method.<T> CtMethod<T>
create(CtType<?> target, Set<ModifierKind> modifiers, CtTypeReference<T> returnType, String name, List<CtParameter<?>> parameters, Set<CtTypeReference<? extends Throwable>> thrownTypes)
Creates an empty method.<T> CtMethod<T>
Creates a method by copying an existing method.<T> CtExecutableReference<T>
createReference(Method method)
Creates a method reference from an actual method.<T> CtExecutableReference<T>
createReference(CtMethod<T> m)
Creates a method reference.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
-
Field Details
-
OBJECT_METHODS
-
-
Constructor Details
-
MethodFactory
Creates a new method sub-factory.- Parameters:
factory
- the parent factory
-
-
Method Details
-
create
public <R, B extends R> CtMethod<R> create(CtClass<?> target, Set<ModifierKind> modifiers, CtTypeReference<R> returnType, String name, List<CtParameter<?>> parameters, Set<CtTypeReference<? extends Throwable>> thrownTypes, CtBlock<B> body)Creates a method.- Parameters:
target
- the class where the method is insertedmodifiers
- the modifiersreturnType
- the method's return typename
- the method's nameparameters
- the parametersthrownTypes
- the thrown typesbody
- the method's body
-
create
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 tosource
- the source method to be copiedredirectReferences
- 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, Set<ModifierKind> modifiers, CtTypeReference<T> returnType, String name, List<CtParameter<?>> parameters, Set<CtTypeReference<? extends Throwable>> thrownTypes)Creates an empty method.- Parameters:
target
- the class where the method is insertedmodifiers
- the modifiersreturnType
- the method's return typename
- the method's nameparameters
- the parametersthrownTypes
- the thrown types
-
createReference
Creates a method reference. -
createReference
Creates a method reference from an actual method. -
getMainMethods
Gets all the main methods stored in this factory.
-