Package io.beanmapper.dynclass
Class ClassGenerator
java.lang.Object
io.beanmapper.dynclass.ClassGenerator
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateClass
(Class<?> baseClass, Node displayNodes, StrictMappingProperties strictMappingProperties) Creates a class, derived from the given base-class.createClassDerivedFromRecord
(Class<? extends Record> clazz, Set<String> fieldNames) Creates a class specifically derived from a Record-class.
-
Constructor Details
-
ClassGenerator
public ClassGenerator() -
ClassGenerator
public ClassGenerator(javassist.ClassPool classPool)
-
-
Method Details
-
createClass
public GeneratedClass createClass(Class<?> baseClass, Node displayNodes, StrictMappingProperties strictMappingProperties) throws javassist.NotFoundException, javassist.CannotCompileException, ClassNotFoundException Creates a class, derived from the given base-class.A class is dynamically generated, whenever a source or target has been downsized, and the given combination of base-class and nodes has not been registered before.
A class will also be generated when an object is mapped to a record.
- Parameters:
baseClass
- The class that will be used to generate a blueprint for the new class.displayNodes
- A wrapper for the fields that need to be present in the resulting class.strictMappingProperties
- Configuration regarding strict mapping.- Returns:
- A
GeneratedClass
-object representing aCtClass
and aClass
. - Throws:
javassist.NotFoundException
- May be thrown when Javassist creates a CtClass based on the name of the given base-class.javassist.CannotCompileException
- If Javassist cannot compile the CtClass to bytecode, a CannotCompileException will be thrown.ClassNotFoundException
-
createClassDerivedFromRecord
public GeneratedClass createClassDerivedFromRecord(Class<? extends Record> clazz, Set<String> fieldNames) throws javassist.NotFoundException, javassist.CannotCompileException Creates a class specifically derived from a Record-class.This method is used whenever a record is used as a source and the configuration allows for the use of converters.
- Parameters:
clazz
- The class that will serve as the baseclass for the dynamically generated class.- Returns:
- A GeneratedClass based on the source class.
- Throws:
javassist.NotFoundException
- May be thrown when Javassist creates a CtClass, based on the name of the given base-class.javassist.CannotCompileException
- If Javassist cannot compile the CtClass to bytecode, a CannotCompileException is thrown.
-