Class ClassFactory


public class ClassFactory extends TypeFactory
The CtClass sub-factory.
  • Constructor Details

    • ClassFactory

      public ClassFactory(Factory factory)
      Creates a class sub-factory.
      Parameters:
      factory - the parent factory
  • Method Details

    • create

      public <T> CtClass<T> create(CtClass<?> declaringClass, String simpleName)
      Creates an inner class.
      Parameters:
      declaringClass - declaring class
      simpleName - simple name of inner class (without . or $)
    • create

      public <T> CtClass<T> create(CtPackage owner, String simpleName)
      Creates a top-level class.
      Parameters:
      owner - the declaring package
      simpleName - the simple name
    • create

      public <T> CtClass<T> create(String qualifiedName)
      Creates a class from its qualified name.
      Type Parameters:
      T - type of created class
      Parameters:
      qualifiedName - full name of class to create. Name can contain $ for inner types
    • get

      public <T> CtClass<T> get(Class<?> cl)
      Gets a class from its runtime Java class.
      Overrides:
      get in class TypeFactory
      Type Parameters:
      T - type of created class
      Parameters:
      cl - the java class: note that this class should be Class<T> but it then poses problem when T is a generic type itself
    • get

      public <T> CtClass<T> get(String qualifiedName)
      Searches for a class from his qualified name.
      Overrides:
      get in class TypeFactory
      Type Parameters:
      T - the type of the class
      Parameters:
      qualifiedName - to search
      Returns:
      found class or null