Class ConstructorFactory


public class ConstructorFactory extends ExecutableFactory
The CtConstructor sub-factory.
  • Constructor Details

    • ConstructorFactory

      public ConstructorFactory(Factory factory)
      Creates a new constructor sub-factory.
      Parameters:
      factory - the parent factory
  • Method Details

    • create

      public <T> CtConstructor<T> create(CtClass<T> target, CtConstructor<?> source)
      Copies a constructor into a target class.
      Parameters:
      target - the target class
      source - the constructor to be copied
      Returns:
      the new constructor
    • create

      public <T> CtConstructor<T> create(CtClass<T> target, CtMethod<?> source)
      Creates a constructor into a target class by copying it from a source method.
      Parameters:
      target - the target class
      source - 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 modifiers
      parameters - the parameters
      thrownTypes - the thrown types
    • createDefault

      public <T> CtConstructor<T> createDefault(CtClass<T> target)
      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 modifiers
      parameters - the parameters
      thrownTypes - the thrown types
      body - the body
    • createReference

      public <T> CtExecutableReference<T> createReference(CtConstructor<T> c)
      Creates a constructor reference from an existing constructor.
    • createReference

      public <T> CtExecutableReference<T> createReference(Constructor<T> constructor)
      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.