Package spoon.reflect.factory
Class ConstructorFactory
java.lang.Object
spoon.reflect.factory.SubFactory
spoon.reflect.factory.ExecutableFactory
spoon.reflect.factory.ConstructorFactory
The
CtConstructor
sub-factory.-
Field Summary
Fields inherited from class spoon.reflect.factory.SubFactory
factory
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T> CtConstructor<T>
create(CtClass<T> target, Set<ModifierKind> modifiers, List<CtParameter<?>> parameters, Set<CtTypeReference<? extends Throwable>> thrownTypes)
Creates an empty constructor.<T> CtConstructor<T>
create(CtClass<T> target, Set<ModifierKind> modifiers, List<CtParameter<?>> parameters, Set<CtTypeReference<? extends Throwable>> thrownTypes, CtBlock<T> body)
Creates a constructor.<T> CtConstructor<T>
create(CtClass<T> target, CtConstructor<?> source)
Copies a constructor into a target class.<T> CtConstructor<T>
Creates a constructor into a target class by copying it from a source method.<T> CtConstructor<T>
createDefault(CtClass<T> target)
Create the default empty constructor.<T> CtExecutableReference<T>
createReference(Constructor<T> constructor)
Creates a constructor reference from an actual constructor.<T> CtExecutableReference<T>
createReference(CtConstructor<T> c)
Creates a constructor reference from an existing constructor.<T> CtExecutableReference<T>
createReference(CtTypeReference<T> type, CtExpression<?>... parameters)
Creates a constructor reference.Methods inherited from class spoon.reflect.factory.ExecutableFactory
createAnonymous, createParameter, createParameterReference, createReference, createReference, createReference, createReference, createReference, createReference
-
Constructor Details
-
ConstructorFactory
Creates a new constructor sub-factory.- Parameters:
factory
- the parent factory
-
-
Method Details
-
create
Copies a constructor into a target class.- Parameters:
target
- the target classsource
- the constructor to be copied- Returns:
- the new constructor
-
create
Creates a constructor into a target class by copying it from a source method.- Parameters:
target
- the target classsource
- the method to be copied- Returns:
- the new constructor
-
create
public <T> CtConstructor<T> create(CtClass<T> target, Set<ModifierKind> modifiers, List<CtParameter<?>> parameters, Set<CtTypeReference<? extends Throwable>> thrownTypes)Creates an empty constructor.- Parameters:
modifiers
- the modifiersparameters
- the parametersthrownTypes
- the thrown types
-
createDefault
Create the default empty constructor.- Parameters:
target
- the class to insert the constructor into- Returns:
- the created constructor
-
create
public <T> CtConstructor<T> create(CtClass<T> target, Set<ModifierKind> modifiers, List<CtParameter<?>> parameters, Set<CtTypeReference<? extends Throwable>> thrownTypes, CtBlock<T> body)Creates a constructor.- Parameters:
modifiers
- the modifiersparameters
- the parametersthrownTypes
- the thrown typesbody
- the body
-
createReference
Creates a constructor reference from an existing constructor. -
createReference
Creates a constructor reference from an actual constructor. -
createReference
public <T> CtExecutableReference<T> createReference(CtTypeReference<T> type, CtExpression<?>... parameters)Creates a constructor reference.- Type Parameters:
T
- Infered type of the constructor.- Parameters:
type
- Declaring type of the constructor.parameters
- Constructor parameters.- Returns:
- CtExecutablereference if a constructor.
-